dart_controller.h 1.2 KB
Newer Older
A
Adam Barth 已提交
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_DART_CONTROLLER_H_
#define FLUTTER_RUNTIME_DART_CONTROLLER_H_
A
Adam Barth 已提交
7

8 9
#include <memory>

A
Adam Barth 已提交
10
#include "dart/runtime/include/dart_api.h"
11
#include "lib/ftl/macros.h"
12
#include "lib/tonic/logging/dart_error.h"
A
Adam Barth 已提交
13 14

namespace blink {
15
class UIDartState;
A
Adam Barth 已提交
16 17 18 19 20 21

class DartController {
 public:
  DartController();
  ~DartController();

22
  void RunFromPrecompiledSnapshot();
23
  void RunFromSnapshot(const uint8_t* buffer, size_t size);
24 25
  tonic::DartErrorHandleType RunFromSource(const std::string& main,
                                           const std::string& packages);
26

27 28
  void CreateIsolateFor(const std::string& script_uri,
                        std::unique_ptr<UIDartState> ui_dart_state);
A
Adam Barth 已提交
29

30
  UIDartState* dart_state() const { return ui_dart_state_; }
A
Adam Barth 已提交
31 32

 private:
33
  bool SendStartMessage(Dart_Handle root_library);
34

35 36 37 38
  // The DartState associated with the main isolate.  This will be deleted
  // during isolate shutdown.
  UIDartState* ui_dart_state_;

39
  FTL_DISALLOW_COPY_AND_ASSIGN(DartController);
A
Adam Barth 已提交
40 41 42
};
}

43
#endif  // FLUTTER_RUNTIME_DART_CONTROLLER_H_