| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 CHECK(!LogIfError(Dart_RunLoop())); | 231 CHECK(!LogIfError(Dart_RunLoop())); |
| 232 handle_watcher_started = true; | 232 handle_watcher_started = true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 // TODO(rafaelw): Right now this only supports the creation of the handle | 235 // TODO(rafaelw): Right now this only supports the creation of the handle |
| 236 // watcher isolate and the service isolate. Presumably, we'll want application | 236 // watcher isolate and the service isolate. Presumably, we'll want application |
| 237 // isolates to spawn their own isolates. | 237 // isolates to spawn their own isolates. |
| 238 static Dart_Isolate IsolateCreateCallback(const char* script_uri, | 238 static Dart_Isolate IsolateCreateCallback(const char* script_uri, |
| 239 const char* main, | 239 const char* main, |
| 240 const char* package_root, | 240 const char* package_root, |
| 241 Dart_IsolateFlags* flags, |
| 241 void* callback_data, | 242 void* callback_data, |
| 242 char** error) { | 243 char** error) { |
| 243 | 244 |
| 244 if (IsServiceIsolateURL(script_uri)) { | 245 if (IsServiceIsolateURL(script_uri)) { |
| 245 CHECK(kDartIsolateSnapshotBuffer); | 246 CHECK(kDartIsolateSnapshotBuffer); |
| 246 DartState* dart_state = new DartState(); | 247 DartState* dart_state = new DartState(); |
| 247 Dart_Isolate isolate = Dart_CreateIsolate(script_uri, | 248 Dart_Isolate isolate = Dart_CreateIsolate(script_uri, |
| 248 "main", | 249 "main", |
| 249 kDartIsolateSnapshotBuffer, | 250 kDartIsolateSnapshotBuffer, |
| 250 nullptr, | 251 nullptr, |
| 252 nullptr, |
| 251 error); | 253 error); |
| 252 CHECK(isolate) << error; | 254 CHECK(isolate) << error; |
| 253 dart_state->SetIsolate(isolate); | 255 dart_state->SetIsolate(isolate); |
| 254 CHECK(Dart_IsServiceIsolate(isolate)); | 256 CHECK(Dart_IsServiceIsolate(isolate)); |
| 255 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); | 257 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); |
| 256 { | 258 { |
| 257 DartApiScope apiScope; | 259 DartApiScope apiScope; |
| 258 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 260 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 259 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); | 261 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| 260 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 262 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 271 } | 273 } |
| 272 } | 274 } |
| 273 Dart_ExitIsolate(); | 275 Dart_ExitIsolate(); |
| 274 return isolate; | 276 return isolate; |
| 275 } | 277 } |
| 276 | 278 |
| 277 // Create & start the handle watcher isolate | 279 // Create & start the handle watcher isolate |
| 278 CHECK(kDartIsolateSnapshotBuffer); | 280 CHECK(kDartIsolateSnapshotBuffer); |
| 279 DartState* dart_state = new DartState(); | 281 DartState* dart_state = new DartState(); |
| 280 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", | 282 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", |
| 281 kDartIsolateSnapshotBuffer, dart_state, error); | 283 kDartIsolateSnapshotBuffer, nullptr, dart_state, error); |
| 282 CHECK(isolate) << error; | 284 CHECK(isolate) << error; |
| 283 dart_state->SetIsolate(isolate); | 285 dart_state->SetIsolate(isolate); |
| 284 | 286 |
| 285 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); | 287 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); |
| 286 | 288 |
| 287 { | 289 { |
| 288 DartApiScope apiScope; | 290 DartApiScope apiScope; |
| 289 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 291 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 290 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); | 292 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| 291 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 293 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 317 Platform::current()->mainThreadTaskRunner()->PostTask(FROM_HERE, | 319 Platform::current()->mainThreadTaskRunner()->PostTask(FROM_HERE, |
| 318 base::Bind(&CallHandleMessage, DartState::From(dest_isolate)->GetWeakPtr()
)); | 320 base::Bind(&CallHandleMessage, DartState::From(dest_isolate)->GetWeakPtr()
)); |
| 319 } | 321 } |
| 320 | 322 |
| 321 void DartController::CreateIsolateFor(PassOwnPtr<DOMDartState> state) { | 323 void DartController::CreateIsolateFor(PassOwnPtr<DOMDartState> state) { |
| 322 CHECK(kDartIsolateSnapshotBuffer); | 324 CHECK(kDartIsolateSnapshotBuffer); |
| 323 char* error = nullptr; | 325 char* error = nullptr; |
| 324 dom_dart_state_ = state; | 326 dom_dart_state_ = state; |
| 325 Dart_Isolate isolate = Dart_CreateIsolate( | 327 Dart_Isolate isolate = Dart_CreateIsolate( |
| 326 dom_dart_state_->url().string().utf8().data(), "main", | 328 dom_dart_state_->url().string().utf8().data(), "main", |
| 327 kDartIsolateSnapshotBuffer, | 329 kDartIsolateSnapshotBuffer, nullptr, |
| 328 static_cast<DartState*>(dom_dart_state_.get()), &error); | 330 static_cast<DartState*>(dom_dart_state_.get()), &error); |
| 329 Dart_SetMessageNotifyCallback(MessageNotifyCallback); | 331 Dart_SetMessageNotifyCallback(MessageNotifyCallback); |
| 330 CHECK(isolate) << error; | 332 CHECK(isolate) << error; |
| 331 dom_dart_state_->SetIsolate(isolate); | 333 dom_dart_state_->SetIsolate(isolate); |
| 332 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); | 334 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); |
| 333 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); | 335 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); |
| 334 | 336 |
| 335 { | 337 { |
| 336 DartApiScope apiScope; | 338 DartApiScope apiScope; |
| 337 | 339 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 nullptr, // Isolate interrupt callback. | 391 nullptr, // Isolate interrupt callback. |
| 390 UnhandledExceptionCallback, IsolateShutdownCallback, | 392 UnhandledExceptionCallback, IsolateShutdownCallback, |
| 391 // File IO callbacks. | 393 // File IO callbacks. |
| 392 nullptr, nullptr, nullptr, nullptr, nullptr)); | 394 nullptr, nullptr, nullptr, nullptr, nullptr)); |
| 393 // Wait for load port- ensures handle watcher and service isolates are | 395 // Wait for load port- ensures handle watcher and service isolates are |
| 394 // running. | 396 // running. |
| 395 Dart_ServiceWaitForLoadPort(); | 397 Dart_ServiceWaitForLoadPort(); |
| 396 } | 398 } |
| 397 | 399 |
| 398 } // namespace blink | 400 } // namespace blink |
| OLD | NEW |