mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Read core platform kernel file during Dart initialization. Currently service isolate is initialized from the source code parsed by VM. This CL changes it so service isolate created during Dart initialization is created from the kernel platform.dill file if it is present in the application bundle. Then this platform kernel file is kept in dart_init module and reused for application sciprt isolates. * Reformat and merge * Use accessor method * Avoid passing running_from_kernel param. Add TODO for cleanup. Rename param.
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
// 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.
|
|
|
|
#ifndef FLUTTER_RUNTIME_DART_CONTROLLER_H_
|
|
#define FLUTTER_RUNTIME_DART_CONTROLLER_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "lib/fxl/macros.h"
|
|
#include "lib/tonic/logging/dart_error.h"
|
|
#include "third_party/dart/runtime/include/dart_api.h"
|
|
|
|
namespace blink {
|
|
class UIDartState;
|
|
|
|
class DartController {
|
|
public:
|
|
DartController();
|
|
~DartController();
|
|
|
|
tonic::DartErrorHandleType RunFromKernel(
|
|
const std::vector<uint8_t>& kernel,
|
|
const std::string& entrypoint = main_entrypoint_);
|
|
tonic::DartErrorHandleType RunFromPrecompiledSnapshot(
|
|
const std::string& entrypoint = main_entrypoint_);
|
|
tonic::DartErrorHandleType RunFromScriptSnapshot(
|
|
const uint8_t* buffer,
|
|
size_t size,
|
|
const std::string& entrypoint = main_entrypoint_);
|
|
tonic::DartErrorHandleType RunFromSource(const std::string& main,
|
|
const std::string& packages);
|
|
|
|
void CreateIsolateFor(const std::string& script_uri,
|
|
const uint8_t* isolate_snapshot_data,
|
|
const uint8_t* isolate_snapshot_instr,
|
|
std::unique_ptr<UIDartState> ui_dart_state);
|
|
|
|
UIDartState* dart_state() const { return ui_dart_state_; }
|
|
|
|
void IsolateShuttingDown();
|
|
|
|
private:
|
|
bool SendStartMessage(Dart_Handle root_library,
|
|
const std::string& entrypoint = main_entrypoint_);
|
|
|
|
static const std::string main_entrypoint_;
|
|
|
|
// The DartState associated with the main isolate. This is not deleted
|
|
// during isolate shutdown, instead it is deleted when the controller
|
|
// object is deleted.
|
|
UIDartState* ui_dart_state_;
|
|
|
|
FXL_DISALLOW_COPY_AND_ASSIGN(DartController);
|
|
};
|
|
} // namespace blink
|
|
|
|
#endif // FLUTTER_RUNTIME_DART_CONTROLLER_H_
|