| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/core/script/dart_controller.h" | 5 #include "sky/engine/core/script/dart_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Dart_Isolate isolate = dart_state()->isolate(); | 142 Dart_Isolate isolate = dart_state()->isolate(); |
| 143 DartIsolateScope isolate_scope(isolate); | 143 DartIsolateScope isolate_scope(isolate); |
| 144 DartApiScope dart_api_scope; | 144 DartApiScope dart_api_scope; |
| 145 | 145 |
| 146 Dart_Handle library = Dart_RootLibrary(); | 146 Dart_Handle library = Dart_RootLibrary(); |
| 147 if (LogIfError(library)) | 147 if (LogIfError(library)) |
| 148 return; | 148 return; |
| 149 DartInvokeAppField(library, ToDart("main"), 0, nullptr); | 149 DartInvokeAppField(library, ToDart("main"), 0, nullptr); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void DartController::LoadSnapshot(const KURL& url, mojo::URLResponsePtr response
) { | 152 void DartController::RunFromSnapshot( |
| 153 mojo::ScopedDataPipeConsumerHandle snapshot) { |
| 153 snapshot_loader_ = adoptPtr(new DartSnapshotLoader(dart_state())); | 154 snapshot_loader_ = adoptPtr(new DartSnapshotLoader(dart_state())); |
| 154 snapshot_loader_->LoadSnapshot( | 155 snapshot_loader_->LoadSnapshot( |
| 155 response->body.Pass(), | 156 snapshot.Pass(), |
| 156 base::Bind(&DartController::DidLoadSnapshot, weak_factory_.GetWeakPtr())); | 157 base::Bind(&DartController::DidLoadSnapshot, weak_factory_.GetWeakPtr())); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void DartController::RunFromLibrary(const String& name, | 160 void DartController::RunFromLibrary(const String& name, |
| 160 DartLibraryProvider* library_provider) { | 161 DartLibraryProvider* library_provider) { |
| 161 DartState::Scope scope(dart_state()); | 162 DartState::Scope scope(dart_state()); |
| 162 CreateEmptyRootLibraryIfNeeded(); | 163 CreateEmptyRootLibraryIfNeeded(); |
| 163 | 164 |
| 164 DartLibraryLoader& loader = dart_state()->library_loader(); | 165 DartLibraryLoader& loader = dart_state()->library_loader(); |
| 165 loader.set_library_provider(library_provider); | 166 loader.set_library_provider(library_provider); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 nullptr, // Isolate interrupt callback. | 429 nullptr, // Isolate interrupt callback. |
| 429 UnhandledExceptionCallback, IsolateShutdownCallback, | 430 UnhandledExceptionCallback, IsolateShutdownCallback, |
| 430 // File IO callbacks. | 431 // File IO callbacks. |
| 431 nullptr, nullptr, nullptr, nullptr, nullptr)); | 432 nullptr, nullptr, nullptr, nullptr, nullptr)); |
| 432 // Wait for load port- ensures handle watcher and service isolates are | 433 // Wait for load port- ensures handle watcher and service isolates are |
| 433 // running. | 434 // running. |
| 434 Dart_ServiceWaitForLoadPort(); | 435 Dart_ServiceWaitForLoadPort(); |
| 435 } | 436 } |
| 436 | 437 |
| 437 } // namespace blink | 438 } // namespace blink |
| OLD | NEW |