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

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

Issue 1130353009: Teach SkyView how to load the main script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 "--enable_asserts", 45 "--enable_asserts",
46 "--enable_type_checks", 46 "--enable_type_checks",
47 "--error_on_bad_type", 47 "--error_on_bad_type",
48 "--error_on_bad_override", 48 "--error_on_bad_override",
49 }; 49 };
50 #endif 50 #endif
51 51
52 extern const uint8_t* kDartVmIsolateSnapshotBuffer; 52 extern const uint8_t* kDartVmIsolateSnapshotBuffer;
53 extern const uint8_t* kDartIsolateSnapshotBuffer; 53 extern const uint8_t* kDartIsolateSnapshotBuffer;
54 54
55 DartController::DartController() { 55 DartController::DartController() : weak_factory_(this) {
56 } 56 }
57 57
58 DartController::~DartController() { 58 DartController::~DartController() {
59 } 59 }
60 60
61 bool DartController::ImportChildLibraries(AbstractModule* module, 61 bool DartController::ImportChildLibraries(AbstractModule* module,
62 Dart_Handle library) { 62 Dart_Handle library) {
63 // If the document has never seen an <import> tag, it won't have an import 63 // If the document has never seen an <import> tag, it won't have an import
64 // controller, and thus will return null for its root HTMLImport. We could 64 // controller, and thus will return null for its root HTMLImport. We could
65 // remove this null-check by always creating an ImportController. 65 // remove this null-check by always creating an ImportController.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 if (LogIfError(library)) 101 if (LogIfError(library))
102 return nullptr; 102 return nullptr;
103 103
104 if (!ImportChildLibraries(module, library)) 104 if (!ImportChildLibraries(module, library))
105 return nullptr; 105 return nullptr;
106 106
107 return library; 107 return library;
108 } 108 }
109 109
110 void DartController::DidLoadMainLibrary(KURL url) {
111 DCHECK(Dart_CurrentIsolate() == dart_state()->isolate());
112 DartApiScope dart_api_scope;
113
114 Dart_Handle library = Dart_LookupLibrary(
115 StringToDart(dart_state(), url.string()));
116 CHECK(!LogIfError(library));
117 DartInvokeAppField(library, ToDart("main"), 0, nullptr);
118 }
119
120 void DartController::LoadMainLibrary(const KURL& url) {
121 DartLoader& loader = dart_state()->loader();
122 DartDependencyCatcher dependency_catcher(loader);
123 loader.LoadLibrary(url);
124 loader.WaitForDependencies(dependency_catcher.dependencies(),
125 base::Bind(&DartController::DidLoadMainLibrary, wea k_factory_.GetWeakPtr(), url));
126 }
127
110 void DartController::LoadScriptInModule( 128 void DartController::LoadScriptInModule(
111 AbstractModule* module, 129 AbstractModule* module,
112 const String& source, 130 const String& source,
113 const TextPosition& position, 131 const TextPosition& position,
114 const LoadFinishedCallback& finished_callback) { 132 const LoadFinishedCallback& finished_callback) {
115 DartIsolateScope isolate_scope(dart_state()->isolate()); 133 DartIsolateScope isolate_scope(dart_state()->isolate());
116 DartApiScope dart_api_scope; 134 DartApiScope dart_api_scope;
117 135
118 DartDependencyCatcher dependency_catcher(dart_state()->loader()); 136 DartDependencyCatcher dependency_catcher(dart_state()->loader());
119 Dart_Handle library_handle = CreateLibrary(module, source, position); 137 Dart_Handle library_handle = CreateLibrary(module, source, position);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 nullptr, // Isolate interrupt callback. 371 nullptr, // Isolate interrupt callback.
354 UnhandledExceptionCallback, IsolateShutdownCallback, 372 UnhandledExceptionCallback, IsolateShutdownCallback,
355 // File IO callbacks. 373 // File IO callbacks.
356 nullptr, nullptr, nullptr, nullptr, nullptr)); 374 nullptr, nullptr, nullptr, nullptr, nullptr));
357 // Wait for load port- ensures handle watcher and service isolates are 375 // Wait for load port- ensures handle watcher and service isolates are
358 // running. 376 // running.
359 Dart_ServiceWaitForLoadPort(); 377 Dart_ServiceWaitForLoadPort();
360 } 378 }
361 379
362 } // namespace blink 380 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698