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

Side by Side Diff: sky/engine/core/script/dart_controller.cc

Issue 1088263004: Ensure isolates have a root library so createMirrorSystem() and spawnUri() are happy. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/tests/dart/mirror-system.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 kDartIsolateSnapshotBuffer, dart_state, error); 197 kDartIsolateSnapshotBuffer, dart_state, error);
198 CHECK(isolate) << error; 198 CHECK(isolate) << error;
199 dart_state->set_isolate(isolate); 199 dart_state->set_isolate(isolate);
200 200
201 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 201 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
202 202
203 { 203 {
204 DartApiScope apiScope; 204 DartApiScope apiScope;
205 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 205 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
206 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); 206 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary);
207
208 // Ensure the isolate has a root library.
209 Dart_LoadScript(Dart_NewStringFromCString("dart:empty"),
210 Dart_NewStringFromCString(""), 0, 0);
207 } 211 }
208 212
209 Dart_ExitIsolate(); 213 Dart_ExitIsolate();
210 214
211 CHECK(Dart_IsolateMakeRunnable(isolate)); 215 CHECK(Dart_IsolateMakeRunnable(isolate));
212 return isolate; 216 return isolate;
213 } 217 }
214 218
215 static void CallHandleMessage(base::WeakPtr<DartState> dart_state) { 219 static void CallHandleMessage(base::WeakPtr<DartState> dart_state) {
216 TRACE_EVENT0("sky", "CallHandleMessage"); 220 TRACE_EVENT0("sky", "CallHandleMessage");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 static_cast<DartState*>(dom_dart_state_.get()), &error); 270 static_cast<DartState*>(dom_dart_state_.get()), &error);
267 Dart_SetMessageNotifyCallback(MessageNotifyCallback); 271 Dart_SetMessageNotifyCallback(MessageNotifyCallback);
268 CHECK(isolate) << error; 272 CHECK(isolate) << error;
269 dom_dart_state_->set_isolate(isolate); 273 dom_dart_state_->set_isolate(isolate);
270 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); 274 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue);
271 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 275 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
272 276
273 { 277 {
274 DartApiScope apiScope; 278 DartApiScope apiScope;
275 279
280 // Ensure the isolate has a root library.
281 Dart_LoadScript(Dart_NewStringFromCString("dart:empty"),
282 Dart_NewStringFromCString(""), 0, 0);
283
276 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 284 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
277 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); 285 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary);
278 BuiltinNatives::Init(); 286 BuiltinNatives::Init();
279 287
280 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state())); 288 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state()));
281 dart_state()->class_library().set_provider(builtin_sky_.get()); 289 dart_state()->class_library().set_provider(builtin_sky_.get());
282 builtin_sky_->InstallWindow(dart_state()); 290 builtin_sky_->InstallWindow(dart_state());
283 291
284 document->frame()->loaderClient()->didCreateIsolate(isolate); 292 document->frame()->loaderClient()->didCreateIsolate(isolate);
285 293
(...skipping 21 matching lines...) Expand all
307 CHECK(Dart_SetVMFlags(argc, argv)); 315 CHECK(Dart_SetVMFlags(argc, argv));
308 CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer, 316 CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer,
309 IsolateCreateCallback, 317 IsolateCreateCallback,
310 nullptr, // Isolate interrupt callback. 318 nullptr, // Isolate interrupt callback.
311 UnhandledExceptionCallback, IsolateShutdownCallback, 319 UnhandledExceptionCallback, IsolateShutdownCallback,
312 // File IO callbacks. 320 // File IO callbacks.
313 nullptr, nullptr, nullptr, nullptr, nullptr)); 321 nullptr, nullptr, nullptr, nullptr, nullptr));
314 } 322 }
315 323
316 } // namespace blink 324 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/tests/dart/mirror-system.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698