Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1269)

Unified Diff: mojo/dart/embedder/dart_controller.cc

Issue 816113004: Dart: Adds a content handler and a test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/dart/embedder/dart_controller.cc
diff --git a/mojo/dart/embedder/dart_controller.cc b/mojo/dart/embedder/dart_controller.cc
index 7ab36a006f809ddd0fc42da6d3acc5c5df8e8c30..93f704ff825ba580e90412167fd0a07c983d328c 100644
--- a/mojo/dart/embedder/dart_controller.cc
+++ b/mojo/dart/embedder/dart_controller.cc
@@ -423,17 +423,10 @@ bool DartController::RunDartScript(const DartControllerConfig& config) {
Dart_Handle result;
Dart_EnterScope();
- Dart_Handle root_lib = Dart_RootLibrary();
- DART_CHECK_VALID(root_lib);
-
- Dart_Handle builtin_lib =
- Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
- DART_CHECK_VALID(builtin_lib);
+ // Start the MojoHandleWatcher.
Dart_Handle mojo_core_lib =
Builtin::LoadAndCheckLibrary(Builtin::kMojoCoreLibrary);
DART_CHECK_VALID(mojo_core_lib);
-
- // Start the MojoHandleWatcher.
Dart_Handle handle_watcher_type = Dart_GetType(
mojo_core_lib,
Dart_NewStringFromCString("MojoHandleWatcher"),
@@ -451,6 +444,12 @@ bool DartController::RunDartScript(const DartControllerConfig& config) {
result = Dart_RunLoop();
DART_CHECK_VALID(result);
+ // Load the root library into the builtin library so that main can be found.
+ Dart_Handle builtin_lib =
+ Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
+ DART_CHECK_VALID(builtin_lib);
+ Dart_Handle root_lib = Dart_RootLibrary();
+ DART_CHECK_VALID(root_lib);
result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null());
DART_CHECK_VALID(result);
@@ -471,9 +470,14 @@ bool DartController::RunDartScript(const DartControllerConfig& config) {
const intptr_t kNumIsolateArgs = 2;
Dart_Handle isolate_args[kNumIsolateArgs];
isolate_args[0] = main_closure; // entryPoint
- isolate_args[1] = Dart_NewList(1); // args
+ isolate_args[1] = Dart_NewList(2); // args
DART_CHECK_VALID(isolate_args[1]);
+
+ Dart_Handle script_uri = Dart_NewStringFromUTF8(
+ reinterpret_cast<const uint8_t*>(config.script_uri.data()),
+ config.script_uri.length());
Dart_ListSetAt(isolate_args[1], 0, Dart_NewInteger(config.handle));
+ Dart_ListSetAt(isolate_args[1], 1, script_uri);
Dart_Handle isolate_lib =
Dart_LookupLibrary(Dart_NewStringFromCString(kIsolateLibURL));

Powered by Google App Engine
This is Rietveld 408576698