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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 dart_state()->loader().WaitForDependencies( | 93 dart_state()->loader().WaitForDependencies( |
94 dependencies, base::Bind(&DartController::ExecuteModule, | 94 dependencies, base::Bind(&DartController::ExecuteModule, |
95 weak_factory_.GetWeakPtr(), module)); | 95 weak_factory_.GetWeakPtr(), module)); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void DartController::ExecuteModule(RefPtr<AbstractModule> module) { | 99 void DartController::ExecuteModule(RefPtr<AbstractModule> module) { |
100 DCHECK(Dart_CurrentIsolate() == dart_state()->isolate()); | 100 DCHECK(Dart_CurrentIsolate() == dart_state()->isolate()); |
101 DartApiScope dart_api_scope; | 101 DartApiScope dart_api_scope; |
102 | 102 |
103 LogIfError(Dart_FinalizeLoading(true)); | 103 // Don't continue if we failed to load the module. |
| 104 if (LogIfError(Dart_FinalizeLoading(true))) |
| 105 return; |
104 Dart_Handle library = module->library()->dart_value(); | 106 Dart_Handle library = module->library()->dart_value(); |
105 const char* name = module->isApplication() ? "main" : "init"; | 107 const char* name = module->isApplication() ? "main" : "init"; |
106 Dart_Handle closure_name = Dart_NewStringFromCString(name); | 108 Dart_Handle closure_name = Dart_NewStringFromCString(name); |
107 Dart_Handle result = Dart_Invoke(library, closure_name, 0, nullptr); | 109 Dart_Handle result = Dart_Invoke(library, closure_name, 0, nullptr); |
108 | 110 |
109 if (module->isApplication()) { | 111 if (module->isApplication()) { |
110 // TODO(dart): This will throw an API error if main() is absent. It would be | 112 // TODO(dart): This will throw an API error if main() is absent. It would be |
111 // better to test whether main() is present first, then attempt to invoke it | 113 // better to test whether main() is present first, then attempt to invoke it |
112 // so as to capture & report other errors. | 114 // so as to capture & report other errors. |
113 LogIfError(result); | 115 LogIfError(result); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 263 |
262 CHECK(Dart_SetVMFlags(argc, argv)); | 264 CHECK(Dart_SetVMFlags(argc, argv)); |
263 CHECK(Dart_Initialize(IsolateCreateCallback, | 265 CHECK(Dart_Initialize(IsolateCreateCallback, |
264 nullptr, // Isolate interrupt callback. | 266 nullptr, // Isolate interrupt callback. |
265 UnhandledExceptionCallback, IsolateShutdownCallback, | 267 UnhandledExceptionCallback, IsolateShutdownCallback, |
266 // File IO callbacks. | 268 // File IO callbacks. |
267 nullptr, nullptr, nullptr, nullptr, nullptr)); | 269 nullptr, nullptr, nullptr, nullptr, nullptr)); |
268 } | 270 } |
269 | 271 |
270 } // namespace blink | 272 } // namespace blink |
OLD | NEW |