未验证 提交 5441ee79 编写于 作者: C Chinmay Garde 提交者: GitHub

Allow embedders to specify a custom advisory URI and entrypoint. (#5408)

The Fuchsia embedder wants to specify the application name in the field for the advisory URI. This allows embedders to specify whatever they want.
上级 8a69d7f7
......@@ -48,6 +48,12 @@ struct Settings {
bool endless_trace_buffer = false;
bool enable_dart_profiling = false;
bool dart_non_checked_mode = false;
// Used as the script URI in debug messages. Does not affect how the Dart code
// is executed.
std::string advisory_script_uri = "main.dart";
// Used as the script entrypoint in debug messages. Does not affect how the
// Dart code is executed.
std::string advisory_script_entrypoint = "main";
// Observatory settings
bool enable_observatory = false;
......
......@@ -46,8 +46,8 @@ class DartIsolate : public UIDartState {
std::unique_ptr<Window> window,
fml::WeakPtr<GrContext> resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue,
std::string advisory_script_uri = "main.dart",
std::string advisory_script_entrypoint = "main",
std::string advisory_script_uri,
std::string advisory_script_entrypoint,
Dart_IsolateFlags* flags = nullptr);
DartIsolate(const DartVM* vm,
......
......@@ -36,7 +36,9 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) {
std::move(task_runners), // task runners
nullptr, // window
{}, // resource context
nullptr // unref qeueue
nullptr, // unref qeueue
"main.dart", // advisory uri
"main" // advisory entrypoint
);
ASSERT_TRUE(root_isolate);
ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup);
......@@ -62,7 +64,9 @@ TEST_F(DartIsolateTest, IsolateCanAssociateSnapshot) {
std::move(task_runners), // task runners
nullptr, // window
{}, // resource context
nullptr // unref qeueue
nullptr, // unref qeueue
"main.dart", // advisory uri
"main" // advisory entrypoint
);
ASSERT_TRUE(root_isolate);
ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup);
......@@ -91,7 +95,9 @@ TEST_F(DartIsolateTest, CanResolveAndInvokeMethod) {
std::move(task_runners), // task runners
nullptr, // window
{}, // resource context
nullptr // unref qeueue
nullptr, // unref qeueue
"main.dart", // advisory uri
"main" // advisory entrypoint
);
ASSERT_TRUE(root_isolate);
ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup);
......
......@@ -25,7 +25,9 @@ RuntimeController::RuntimeController(
fxl::RefPtr<DartSnapshot> p_shared_snapshot,
TaskRunners p_task_runners,
fml::WeakPtr<GrContext> p_resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> p_unref_queue)
fxl::RefPtr<flow::SkiaUnrefQueue> p_unref_queue,
std::string p_advisory_script_uri,
std::string p_advisory_script_entrypoint)
: RuntimeController(p_client,
p_vm,
std::move(p_isolate_snapshot),
......@@ -33,6 +35,8 @@ RuntimeController::RuntimeController(
std::move(p_task_runners),
std::move(p_resource_context),
std::move(p_unref_queue),
std::move(p_advisory_script_uri),
std::move(p_advisory_script_entrypoint),
WindowData{/* default window data */}) {}
RuntimeController::RuntimeController(
......@@ -43,6 +47,8 @@ RuntimeController::RuntimeController(
TaskRunners p_task_runners,
fml::WeakPtr<GrContext> p_resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> p_unref_queue,
std::string p_advisory_script_uri,
std::string p_advisory_script_entrypoint,
WindowData p_window_data)
: client_(p_client),
vm_(p_vm),
......@@ -51,6 +57,8 @@ RuntimeController::RuntimeController(
task_runners_(p_task_runners),
resource_context_(p_resource_context),
unref_queue_(p_unref_queue),
advisory_script_uri_(p_advisory_script_uri),
advisory_script_entrypoint_(p_advisory_script_entrypoint),
window_data_(std::move(p_window_data)),
root_isolate_(
DartIsolate::CreateRootIsolate(vm_,
......@@ -59,7 +67,9 @@ RuntimeController::RuntimeController(
task_runners_,
std::make_unique<Window>(this),
resource_context_,
unref_queue_)) {
unref_queue_,
p_advisory_script_uri,
p_advisory_script_entrypoint)) {
root_isolate_->SetReturnCodeCallback([this](uint32_t code) {
root_isolate_return_code_ = {true, code};
});
......@@ -96,14 +106,16 @@ bool RuntimeController::IsRootIsolateRunning() const {
std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
return std::unique_ptr<RuntimeController>(new RuntimeController(
client_, //
vm_, //
isolate_snapshot_, //
shared_snapshot_, //
task_runners_, //
resource_context_, //
unref_queue_, //
window_data_ //
client_, //
vm_, //
isolate_snapshot_, //
shared_snapshot_, //
task_runners_, //
resource_context_, //
unref_queue_, //
advisory_script_uri_, //
advisory_script_entrypoint_, //
window_data_ //
));
}
......
......@@ -29,7 +29,9 @@ class RuntimeController final : public WindowClient {
fxl::RefPtr<DartSnapshot> shared_snapshot,
TaskRunners task_runners,
fml::WeakPtr<GrContext> resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue);
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue,
std::string advisory_script_uri,
std::string advisory_script_entrypoint);
~RuntimeController();
......@@ -86,6 +88,8 @@ class RuntimeController final : public WindowClient {
TaskRunners task_runners_;
fml::WeakPtr<GrContext> resource_context_;
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue_;
std::string advisory_script_uri_;
std::string advisory_script_entrypoint_;
WindowData window_data_;
fml::WeakPtr<DartIsolate> root_isolate_;
std::pair<bool, uint32_t> root_isolate_return_code_ = {false, 0};
......@@ -97,6 +101,8 @@ class RuntimeController final : public WindowClient {
TaskRunners task_runners,
fml::WeakPtr<GrContext> resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue,
std::string advisory_script_uri,
std::string advisory_script_entrypoint,
WindowData data);
Window* GetWindowIfAvailable();
......
......@@ -55,13 +55,15 @@ Engine::Engine(Delegate& delegate,
// object as its delegate. The delegate may be called in the constructor and
// we want to be fully initilazed by that point.
runtime_controller_ = std::make_unique<blink::RuntimeController>(
*this, // runtime delegate
&vm, // VM
std::move(isolate_snapshot), // isolate snapshot
std::move(shared_snapshot), // shared snapshot
std::move(task_runners), // task runners
std::move(resource_context), // resource context
std::move(unref_queue) // skia unref queue
*this, // runtime delegate
&vm, // VM
std::move(isolate_snapshot), // isolate snapshot
std::move(shared_snapshot), // shared snapshot
std::move(task_runners), // task runners
std::move(resource_context), // resource context
std::move(unref_queue), // skia unref queue
settings_.advisory_script_uri, // advisory script uri
settings_.advisory_script_entrypoint // advisory script entrypoint
);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册