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

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

Issue 956653003: Dart: Moves |native| methods to patch files. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Adjust analyzer script Created 5 years, 9 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 | « sky/engine/bindings/builtin_sky.cc ('k') | no next file » | 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 DartState* dart_state = new DartState(); 192 DartState* dart_state = new DartState();
193 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", 193 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "",
194 kDartSnapshotBuffer, dart_state, error); 194 kDartSnapshotBuffer, dart_state, error);
195 CHECK(isolate) << error; 195 CHECK(isolate) << error;
196 dart_state->set_isolate(isolate); 196 dart_state->set_isolate(isolate);
197 197
198 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 198 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
199 199
200 { 200 {
201 DartApiScope apiScope; 201 DartApiScope apiScope;
202 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 202 Builtin::PrepareLibrary(Builtin::kBuiltinLibrary);
203 Builtin::SetNativeResolver(Builtin::kMojoCoreLibrary); 203 Builtin::PrepareLibrary(Builtin::kMojoCoreLibrary);
204 } 204 }
205 205
206 Dart_ExitIsolate(); 206 Dart_ExitIsolate();
207 207
208 CHECK(Dart_IsolateMakeRunnable(isolate)); 208 CHECK(Dart_IsolateMakeRunnable(isolate));
209 return isolate; 209 return isolate;
210 } 210 }
211 211
212 static void CallHandleMessage(base::WeakPtr<DartState> dart_state) { 212 static void CallHandleMessage(base::WeakPtr<DartState> dart_state) {
213 if (!dart_state) 213 if (!dart_state)
(...skipping 10 matching lines...) Expand all
224 base::Bind(&CallHandleMessage, DartState::From(dest_isolate)->GetWeakPtr() )); 224 base::Bind(&CallHandleMessage, DartState::From(dest_isolate)->GetWeakPtr() ));
225 } 225 }
226 226
227 static void EnsureHandleWatcherStarted() { 227 static void EnsureHandleWatcherStarted() {
228 static bool handle_watcher_started = false; 228 static bool handle_watcher_started = false;
229 if (handle_watcher_started) 229 if (handle_watcher_started)
230 return; 230 return;
231 231
232 // TODO(dart): Call Dart_Cleanup (ensure the handle watcher isolate is closed) 232 // TODO(dart): Call Dart_Cleanup (ensure the handle watcher isolate is closed)
233 // during shutdown. 233 // during shutdown.
234 Dart_Handle mojo_core_lib = 234 Dart_Handle mojo_core_lib = Builtin::GetLibrary(Builtin::kMojoCoreLibrary);
235 Builtin::LoadAndCheckLibrary(Builtin::kMojoCoreLibrary);
236 CHECK(!LogIfError((mojo_core_lib))); 235 CHECK(!LogIfError((mojo_core_lib)));
237 Dart_Handle handle_watcher_type = Dart_GetType( 236 Dart_Handle handle_watcher_type = Dart_GetType(
238 mojo_core_lib, 237 mojo_core_lib,
239 Dart_NewStringFromCString("MojoHandleWatcher"), 238 Dart_NewStringFromCString("MojoHandleWatcher"),
240 0, 239 0,
241 nullptr); 240 nullptr);
242 CHECK(!LogIfError(handle_watcher_type)); 241 CHECK(!LogIfError(handle_watcher_type));
243 CHECK(!LogIfError(Dart_Invoke( 242 CHECK(!LogIfError(Dart_Invoke(
244 handle_watcher_type, 243 handle_watcher_type,
245 Dart_NewStringFromCString("_start"), 244 Dart_NewStringFromCString("_start"),
(...skipping 15 matching lines...) Expand all
261 static_cast<DartState*>(dom_dart_state_.get()), &error); 260 static_cast<DartState*>(dom_dart_state_.get()), &error);
262 Dart_SetMessageNotifyCallback(MessageNotifyCallback); 261 Dart_SetMessageNotifyCallback(MessageNotifyCallback);
263 CHECK(isolate) << error; 262 CHECK(isolate) << error;
264 dom_dart_state_->set_isolate(isolate); 263 dom_dart_state_->set_isolate(isolate);
265 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); 264 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue);
266 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 265 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
267 266
268 { 267 {
269 DartApiScope apiScope; 268 DartApiScope apiScope;
270 269
271 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 270 Builtin::PrepareLibrary(Builtin::kBuiltinLibrary);
272 Builtin::SetNativeResolver(Builtin::kMojoCoreLibrary); 271 Builtin::PrepareLibrary(Builtin::kMojoCoreLibrary);
273 BuiltinNatives::Init(); 272 BuiltinNatives::Init();
274 273
275 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state())); 274 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state()));
276 dart_state()->class_library().set_provider(builtin_sky_.get()); 275 dart_state()->class_library().set_provider(builtin_sky_.get());
277 builtin_sky_->InstallWindow(dart_state()); 276 builtin_sky_->InstallWindow(dart_state());
278 277
279 document->frame()->loaderClient()->didCreateIsolate(isolate); 278 document->frame()->loaderClient()->didCreateIsolate(isolate);
280 279
281 EnsureHandleWatcherStarted(); 280 EnsureHandleWatcherStarted();
282 } 281 }
(...skipping 18 matching lines...) Expand all
301 300
302 CHECK(Dart_SetVMFlags(argc, argv)); 301 CHECK(Dart_SetVMFlags(argc, argv));
303 CHECK(Dart_Initialize(IsolateCreateCallback, 302 CHECK(Dart_Initialize(IsolateCreateCallback,
304 nullptr, // Isolate interrupt callback. 303 nullptr, // Isolate interrupt callback.
305 UnhandledExceptionCallback, IsolateShutdownCallback, 304 UnhandledExceptionCallback, IsolateShutdownCallback,
306 // File IO callbacks. 305 // File IO callbacks.
307 nullptr, nullptr, nullptr, nullptr, nullptr)); 306 nullptr, nullptr, nullptr, nullptr, nullptr));
308 } 307 }
309 308
310 } // namespace blink 309 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings/builtin_sky.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698