Chromium Code Reviews| 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/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/script/dart_controller.h" | 6 #include "sky/engine/core/script/dart_controller.h" |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 #if ENABLE(ASSERT) | 40 #if ENABLE(ASSERT) |
| 41 static const char* kCheckedModeArgs[] = { | 41 static const char* kCheckedModeArgs[] = { |
| 42 "--enable_asserts", | 42 "--enable_asserts", |
| 43 "--enable_type_checks", | 43 "--enable_type_checks", |
| 44 "--error_on_bad_type", | 44 "--error_on_bad_type", |
| 45 "--error_on_bad_override", | 45 "--error_on_bad_override", |
| 46 }; | 46 }; |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 extern const uint8_t* kDartSnapshotBuffer; | 49 extern const uint8_t* kDartVmIsolateSnapshotBuffer; |
| 50 extern const uint8_t* kDartIsolateSnapshotBuffer; | |
| 50 | 51 |
| 51 DartController::DartController() { | 52 DartController::DartController() { |
| 52 } | 53 } |
| 53 | 54 |
| 54 DartController::~DartController() { | 55 DartController::~DartController() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 bool DartController::ImportChildLibraries(AbstractModule* module, | 58 bool DartController::ImportChildLibraries(AbstractModule* module, |
| 58 Dart_Handle library) { | 59 Dart_Handle library) { |
| 59 // If the document has never seen an <import> tag, it won't have an import | 60 // If the document has never seen an <import> tag, it won't have an import |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // TODO(rafaelw): Right now this only supports the creation of the handle | 179 // TODO(rafaelw): Right now this only supports the creation of the handle |
| 179 // watcher isolate. Presumably, we'll want application isolates to spawn their | 180 // watcher isolate. Presumably, we'll want application isolates to spawn their |
| 180 // own isolates. | 181 // own isolates. |
| 181 static Dart_Isolate IsolateCreateCallback(const char* script_uri, | 182 static Dart_Isolate IsolateCreateCallback(const char* script_uri, |
| 182 const char* main, | 183 const char* main, |
| 183 const char* package_root, | 184 const char* package_root, |
| 184 void* callback_data, | 185 void* callback_data, |
| 185 char** error) { | 186 char** error) { |
| 186 | 187 |
| 187 if (IsServiceIsolateURL(script_uri)) { | 188 if (IsServiceIsolateURL(script_uri)) { |
| 188 return Dart_CreateIsolate(script_uri, "main", kDartSnapshotBuffer, nullptr, | 189 return Dart_CreateIsolate(script_uri, "main", kDartIsolateSnapshotBuffer, |
| 189 error); | 190 nullptr, error); |
| 190 } | 191 } |
| 191 | 192 |
| 192 // Create & start the handle watcher isolate | 193 // Create & start the handle watcher isolate |
| 193 CHECK(kDartSnapshotBuffer); | 194 CHECK(kDartIsolateSnapshotBuffer); |
| 194 DartState* dart_state = new DartState(); | 195 DartState* dart_state = new DartState(); |
| 195 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", | 196 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", |
| 196 kDartSnapshotBuffer, dart_state, error); | 197 kDartIsolateSnapshotBuffer, dart_state, error); |
| 197 CHECK(isolate) << error; | 198 CHECK(isolate) << error; |
| 198 dart_state->set_isolate(isolate); | 199 dart_state->set_isolate(isolate); |
| 199 | 200 |
| 200 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); | 201 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); |
| 201 | 202 |
| 202 { | 203 { |
| 203 DartApiScope apiScope; | 204 DartApiScope apiScope; |
| 204 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 205 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 205 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); | 206 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| 206 } | 207 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 0, | 251 0, |
| 251 nullptr))); | 252 nullptr))); |
| 252 | 253 |
| 253 // RunLoop until the handle watcher isolate is spun-up. | 254 // RunLoop until the handle watcher isolate is spun-up. |
| 254 CHECK(!LogIfError(Dart_RunLoop())); | 255 CHECK(!LogIfError(Dart_RunLoop())); |
| 255 handle_watcher_started = true; | 256 handle_watcher_started = true; |
| 256 } | 257 } |
| 257 | 258 |
| 258 void DartController::CreateIsolateFor(Document* document) { | 259 void DartController::CreateIsolateFor(Document* document) { |
| 259 DCHECK(document); | 260 DCHECK(document); |
| 260 CHECK(kDartSnapshotBuffer); | 261 CHECK(kDartIsolateSnapshotBuffer); |
| 261 char* error = nullptr; | 262 char* error = nullptr; |
| 262 dom_dart_state_ = adoptPtr(new DOMDartState(document)); | 263 dom_dart_state_ = adoptPtr(new DOMDartState(document)); |
| 263 Dart_Isolate isolate = Dart_CreateIsolate( | 264 Dart_Isolate isolate = Dart_CreateIsolate( |
| 264 document->url().string().utf8().data(), "main", kDartSnapshotBuffer, | 265 document->url().string().utf8().data(), "main", kDartIsolateSnapshotBuffer , |
| 265 static_cast<DartState*>(dom_dart_state_.get()), &error); | 266 static_cast<DartState*>(dom_dart_state_.get()), &error); |
| 266 Dart_SetMessageNotifyCallback(MessageNotifyCallback); | 267 Dart_SetMessageNotifyCallback(MessageNotifyCallback); |
| 267 CHECK(isolate) << error; | 268 CHECK(isolate) << error; |
| 268 dom_dart_state_->set_isolate(isolate); | 269 dom_dart_state_->set_isolate(isolate); |
| 269 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); | 270 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); |
| 270 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); | 271 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); |
| 271 | 272 |
| 272 { | 273 { |
| 273 DartApiScope apiScope; | 274 DartApiScope apiScope; |
| 274 | 275 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 297 void DartController::InitVM() { | 298 void DartController::InitVM() { |
| 298 int argc = 0; | 299 int argc = 0; |
| 299 const char** argv = nullptr; | 300 const char** argv = nullptr; |
| 300 | 301 |
| 301 #if ENABLE(ASSERT) | 302 #if ENABLE(ASSERT) |
| 302 argc = arraysize(kCheckedModeArgs); | 303 argc = arraysize(kCheckedModeArgs); |
| 303 argv = kCheckedModeArgs; | 304 argv = kCheckedModeArgs; |
| 304 #endif | 305 #endif |
| 305 | 306 |
| 306 CHECK(Dart_SetVMFlags(argc, argv)); | 307 CHECK(Dart_SetVMFlags(argc, argv)); |
| 307 CHECK(Dart_Initialize(IsolateCreateCallback, | 308 CHECK(Dart_Initialize(nullptr, // VM Isolate snapshot buffer. |
|
zra
2015/03/31 14:37:33
nullptr -> kDartVmIsolateSnapshotBuffer
siva
2015/03/31 19:52:20
Done.
| |
| 309 IsolateCreateCallback, | |
| 308 nullptr, // Isolate interrupt callback. | 310 nullptr, // Isolate interrupt callback. |
| 309 UnhandledExceptionCallback, IsolateShutdownCallback, | 311 UnhandledExceptionCallback, IsolateShutdownCallback, |
| 310 // File IO callbacks. | 312 // File IO callbacks. |
| 311 nullptr, nullptr, nullptr, nullptr, nullptr)); | 313 nullptr, nullptr, nullptr, nullptr, nullptr)); |
| 312 } | 314 } |
| 313 | 315 |
| 314 } // namespace blink | 316 } // namespace blink |
| OLD | NEW |