Chromium Code Reviews| Index: sky/engine/core/script/dart_controller.cc |
| diff --git a/sky/engine/core/script/dart_controller.cc b/sky/engine/core/script/dart_controller.cc |
| index 80338ba8a09fae1cd1814509ad918776c44510c9..ea06ed2836b661fabccdd38d791b60e22e5ae575 100644 |
| --- a/sky/engine/core/script/dart_controller.cc |
| +++ b/sky/engine/core/script/dart_controller.cc |
| @@ -27,6 +27,7 @@ |
| #include "sky/engine/core/script/dart_dependency_catcher.h" |
| #include "sky/engine/core/script/dart_loader.h" |
| #include "sky/engine/core/script/dart_service_isolate.h" |
| +#include "sky/engine/core/script/dart_snapshot_loader.h" |
| #include "sky/engine/core/script/dom_dart_state.h" |
| #include "sky/engine/public/platform/Platform.h" |
| #include "sky/engine/tonic/dart_api_scope.h" |
| @@ -133,6 +134,26 @@ void DartController::LoadMainLibrary(const KURL& url, mojo::URLResponsePtr respo |
| base::Bind(&DartController::DidLoadMainLibrary, weak_factory_.GetWeakPtr(), url)); |
| } |
| +void DartController::DidLoadSnapshot() { |
| + DCHECK(Dart_CurrentIsolate() == nullptr); |
| + snapshot_loader_ = nullptr; |
| + |
| + Dart_Isolate isolate = dart_state()->isolate(); |
| + DartIsolateScope isolate_scope(isolate); |
| + DartApiScope dart_api_scope; |
| + |
| + Dart_Handle library = Dart_RootLibrary(); |
| + if (LogIfError(library)) |
| + return; |
| + DartInvokeAppField(library, ToDart("main"), 0, nullptr); |
| +} |
| + |
| +void DartController::LoadSnapshot(const KURL& url, mojo::URLResponsePtr response) { |
| + snapshot_loader_ = adoptPtr(new DartSnapshotLoader(dart_state())); |
| + snapshot_loader_->LoadSnapshot(url, response.Pass(), |
| + base::Bind(&DartController::DidLoadSnapshot, weak_factory_.GetWeakPtr())); |
| +} |
| + |
| void DartController::LoadScriptInModule( |
| AbstractModule* module, |
| const String& source, |
| @@ -289,9 +310,11 @@ static Dart_Isolate IsolateCreateCallback(const char* script_uri, |
| Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| - // Ensure the isolate has a root library. |
| - Dart_LoadScript(Dart_NewStringFromCString("dart:empty"), |
| - Dart_NewStringFromCString(""), 0, 0); |
| + if (!script_uri) { |
| + // Ensure the isolate has a root library. |
|
eseidel
2015/06/23 06:21:39
I don't think this is necessary anymore This was
abarth-chromium
2015/06/23 14:50:42
Yeah, I was close to removing it entirely. I thin
eseidel
2015/06/23 16:02:03
My recollection was it was needed because of the w
|
| + Dart_LoadScript(Dart_NewStringFromCString("dart:empty"), |
| + Dart_EmptyString(), 0, 0); |
| + } |
| } |
| Dart_ExitIsolate(); |
| @@ -334,10 +357,6 @@ void DartController::CreateIsolateFor(PassOwnPtr<DOMDartState> state) { |
| { |
| DartApiScope apiScope; |
| - // Ensure the isolate has a root library. |
| - Dart_LoadScript(Dart_NewStringFromCString("dart:empty"), |
| - Dart_NewStringFromCString(""), 0, 0); |
| - |
| Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| Builtin::SetNativeResolver(Builtin::kIOLibrary); |