ui_dart_state.h 2.1 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_LIB_UI_UI_DART_STATE_H_
#define FLUTTER_LIB_UI_UI_DART_STATE_H_
7

8 9
#include <utility>

A
Adam Barth 已提交
10
#include "flutter/sky/engine/wtf/RefPtr.h"
11
#include "lib/fxl/build_config.h"
12
#include "lib/tonic/dart_persistent_value.h"
13
#include "lib/tonic/dart_state.h"
14
#include "third_party/dart/runtime/include/dart_api.h"
15 16

namespace blink {
17 18
class FontSelector;
class Window;
19

20 21 22 23 24 25 26 27 28
class IsolateClient {
 public:
  virtual void DidCreateSecondaryIsolate(Dart_Isolate isolate) = 0;
  virtual void DidShutdownMainIsolate() = 0;

 protected:
  virtual ~IsolateClient();
};

29
class UIDartState : public tonic::DartState {
30
 public:
31 32 33 34 35
  UIDartState(IsolateClient* isolate_client,
              std::unique_ptr<Window> window,
              int dirfd = -1);
  ~UIDartState() override;

36
  static UIDartState* Current();
37

38
  UIDartState* CreateForChildIsolate();
39

40 41 42 43 44
  IsolateClient* isolate_client() const { return isolate_client_; }
  void set_isolate_client(IsolateClient* isolate_client) {
    isolate_client_ = isolate_client;
  }
  Dart_Port main_port() const { return main_port_; }
45
  const std::string& debug_name() const { return debug_name_; }
46 47
  Window* window() const { return window_.get(); }

48
  void set_debug_name_prefix(const std::string& debug_name_prefix);
49 50
  void set_font_selector(PassRefPtr<FontSelector> selector);
  PassRefPtr<FontSelector> font_selector();
51 52 53 54
  bool is_controller_state() const { return is_controller_state_; }
  void set_is_controller_state(bool value) { is_controller_state_ = value; }
  bool shutting_down() const { return shutting_down_; }
  void set_shutting_down(bool value) { shutting_down_ = value; }
55 56

 private:
57
  void DidSetIsolate() override;
58

59 60 61
  IsolateClient* isolate_client_;
  Dart_Port main_port_;
  std::string debug_name_prefix_;
62
  std::string debug_name_;
63
  std::unique_ptr<Window> window_;
A
Adam Barth 已提交
64
  RefPtr<FontSelector> font_selector_;
65 66
  bool is_controller_state_;
  bool shutting_down_ = false;
67 68 69 70
};

}  // namespace blink

71
#endif  // FLUTTER_LIB_UI_UI_DART_STATE_H_