runtime_controller.h 2.6 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
7 8

#include <memory>
9

10
#include "flutter/flow/layers/layer_tree.h"
11
#include "flutter/lib/ui/ui_dart_state.h"
12
#include "flutter/lib/ui/window/pointer_data_packet.h"
13
#include "flutter/lib/ui/window/window.h"
14
#include "lib/fxl/macros.h"
15 16

namespace blink {
17
class DartController;
18
class DartLibraryProvider;
19
class Scene;
20
class RuntimeDelegate;
21
class View;
22
class Window;
23

24
class RuntimeController : public WindowClient, public IsolateClient {
25
 public:
26 27 28
  static std::unique_ptr<RuntimeController> Create(RuntimeDelegate* client);
  ~RuntimeController();

R
Ryan Macnak 已提交
29 30
  void CreateDartController(const std::string& script_uri,
                            const uint8_t* isolate_snapshot_data,
31 32
                            const uint8_t* isolate_snapshot_instr,
                            int dirfd = -1);
33
  DartController* dart_controller() const { return dart_controller_.get(); }
34

35
  void SetViewportMetrics(const ViewportMetrics& metrics);
36
  void SetLocale(const std::string& language_code,
A
Adam Barth 已提交
37
                 const std::string& country_code);
38
  void SetUserSettingsData(const std::string& data);
39
  void SetSemanticsEnabled(bool enabled);
40

41
  void BeginFrame(fxl::TimePoint frame_time);
42
  void NotifyIdle(int64_t deadline);
43

44
  void DispatchPlatformMessage(fxl::RefPtr<PlatformMessage> message);
45
  void DispatchPointerDataPacket(const PointerDataPacket& packet);
46 47 48
  void DispatchSemanticsAction(int32_t id,
                               SemanticsAction action,
                               std::vector<uint8_t> args);
49

50
  Dart_Port GetMainPort();
51
  std::string GetIsolateName();
52
  bool HasLivePorts();
53
  tonic::DartErrorHandleType GetLastError();
54

55
 private:
56
  explicit RuntimeController(RuntimeDelegate* client);
57

58 59
  Window* GetWindow();

60
  std::string DefaultRouteName() override;
61 62
  void ScheduleFrame() override;
  void Render(Scene* scene) override;
63
  void UpdateSemantics(SemanticsUpdate* update) override;
64
  void HandlePlatformMessage(fxl::RefPtr<PlatformMessage> message) override;
A
Adam Barth 已提交
65

66
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;
67
  void DidShutdownMainIsolate() override;
68

69
  RuntimeDelegate* client_;
70 71
  std::string language_code_;
  std::string country_code_;
72
  std::string user_settings_data_ = "{}";
73
  bool semantics_enabled_ = false;
74
  std::unique_ptr<DartController> dart_controller_;
A
Adam Barth 已提交
75

76
  FXL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
77 78
};

A
Adam Barth 已提交
79
}  // namespace blink
80

81
#endif  // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_