Skip to content

Commit

Permalink
Allow embedders to specify a custom advisory URI and entrypoint. (flu…
Browse files Browse the repository at this point in the history
…tter#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.
  • Loading branch information
chinmaygarde authored May 29, 2018
1 parent 8a69d7f commit 5441ee7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 23 deletions.
6 changes: 6 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions runtime/dart_isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions runtime/dart_isolate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
32 changes: 22 additions & 10 deletions runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ 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),
std::move(p_shared_snapshot),
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(
Expand All @@ -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),
Expand All @@ -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_,
Expand All @@ -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};
});
Expand Down Expand Up @@ -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_ //
));
}

Expand Down
8 changes: 7 additions & 1 deletion runtime/runtime_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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};
Expand All @@ -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();
Expand Down
16 changes: 9 additions & 7 deletions shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down

0 comments on commit 5441ee7

Please sign in to comment.