runtime_controller.h 1.9 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 12
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/window/window.h"
13 14
#include "flutter/services/engine/sky_engine.mojom.h"
#include "flutter/services/pointer/pointer.mojom.h"
15
#include "lib/ftl/macros.h"
16 17

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

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

  void CreateDartController(const std::string& script_uri);
  DartController* dart_controller() const { return dart_controller_.get(); }
32

33
  void SetViewportMetrics(const sky::ViewportMetricsPtr& metrics);
34
  void SetLocale(const std::string& language_code,
A
Adam Barth 已提交
35
                 const std::string& country_code);
A
Adam Barth 已提交
36 37
  void PushRoute(const std::string& route);
  void PopRoute();
38

A
Adam Barth 已提交
39
  void BeginFrame(ftl::TimePoint frame_time);
40

41
  void HandlePointerPacket(const pointer::PointerPacketPtr& packet);
42

43 44
  void OnAppLifecycleStateChanged(sky::AppLifecycleState state);

45 46
  Dart_Port GetMainPort();

47
 private:
48
  explicit RuntimeController(RuntimeDelegate* client);
49

50 51 52 53
  Window* GetWindow();

  void ScheduleFrame() override;
  void Render(Scene* scene) override;
A
Adam Barth 已提交
54

55 56
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;

57
  RuntimeDelegate* client_;
58
  sky::ViewportMetricsPtr viewport_metrics_;
59 60
  std::string language_code_;
  std::string country_code_;
61
  std::unique_ptr<DartController> dart_controller_;
A
Adam Barth 已提交
62

63
  FTL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
64 65
};

A
Adam Barth 已提交
66
}  // namespace blink
67

68
#endif  // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_