| 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 10 matching lines...) Expand all Loading... |
| 21 #include "sky/engine/core/html/imports/HTMLImportChild.h" | 21 #include "sky/engine/core/html/imports/HTMLImportChild.h" |
| 22 #include "sky/engine/core/loader/FrameLoaderClient.h" | 22 #include "sky/engine/core/loader/FrameLoaderClient.h" |
| 23 #include "sky/engine/core/script/dart_dependency_catcher.h" | 23 #include "sky/engine/core/script/dart_dependency_catcher.h" |
| 24 #include "sky/engine/core/script/dart_loader.h" | 24 #include "sky/engine/core/script/dart_loader.h" |
| 25 #include "sky/engine/core/script/dom_dart_state.h" | 25 #include "sky/engine/core/script/dom_dart_state.h" |
| 26 #include "sky/engine/public/platform/Platform.h" | 26 #include "sky/engine/public/platform/Platform.h" |
| 27 #include "sky/engine/tonic/dart_api_scope.h" | 27 #include "sky/engine/tonic/dart_api_scope.h" |
| 28 #include "sky/engine/tonic/dart_class_library.h" | 28 #include "sky/engine/tonic/dart_class_library.h" |
| 29 #include "sky/engine/tonic/dart_error.h" | 29 #include "sky/engine/tonic/dart_error.h" |
| 30 #include "sky/engine/tonic/dart_gc_controller.h" | 30 #include "sky/engine/tonic/dart_gc_controller.h" |
| 31 #include "sky/engine/tonic/dart_invoke.h" |
| 31 #include "sky/engine/tonic/dart_isolate_scope.h" | 32 #include "sky/engine/tonic/dart_isolate_scope.h" |
| 32 #include "sky/engine/tonic/dart_state.h" | 33 #include "sky/engine/tonic/dart_state.h" |
| 33 #include "sky/engine/tonic/dart_wrappable.h" | 34 #include "sky/engine/tonic/dart_wrappable.h" |
| 34 #include "sky/engine/wtf/text/TextPosition.h" | 35 #include "sky/engine/wtf/text/TextPosition.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 #if ENABLE(ASSERT) | 39 #if ENABLE(ASSERT) |
| 39 static const char* kCheckedModeArgs[] = { | 40 static const char* kCheckedModeArgs[] = { |
| 40 "--enable_asserts", | 41 "--enable_asserts", |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 133 |
| 133 // Don't continue if we failed to load the module. | 134 // Don't continue if we failed to load the module. |
| 134 if (LogIfError(Dart_FinalizeLoading(true))) | 135 if (LogIfError(Dart_FinalizeLoading(true))) |
| 135 return; | 136 return; |
| 136 const char* name = module->isApplication() ? "main" : "_init"; | 137 const char* name = module->isApplication() ? "main" : "_init"; |
| 137 | 138 |
| 138 // main() is required, but init() is not: | 139 // main() is required, but init() is not: |
| 139 // TODO(rmacnak): Dart_LookupFunction won't find re-exports, etc. | 140 // TODO(rmacnak): Dart_LookupFunction won't find re-exports, etc. |
| 140 Dart_Handle entry = Dart_LookupFunction(library, ToDart(name)); | 141 Dart_Handle entry = Dart_LookupFunction(library, ToDart(name)); |
| 141 if (module->isApplication()) { | 142 if (module->isApplication()) { |
| 142 LogIfError(Dart_Invoke(library, ToDart(name), 0, nullptr)); | 143 DartInvokeAppField(library, ToDart(name), 0, nullptr); |
| 143 return; | 144 return; |
| 144 } | 145 } |
| 145 | 146 |
| 146 if (!Dart_IsFunction(entry)) | 147 if (!Dart_IsFunction(entry)) |
| 147 return; | 148 return; |
| 148 | 149 |
| 149 Dart_Handle args[] = { | 150 Dart_Handle args[] = { |
| 150 ToDart(script), | 151 ToDart(script), |
| 151 }; | 152 }; |
| 152 LogIfError(Dart_Invoke(library, ToDart(name), arraysize(args), args)); | 153 DartInvokeAppField(library, ToDart(name), arraysize(args), args); |
| 153 } | 154 } |
| 154 | 155 |
| 155 static void UnhandledExceptionCallback(Dart_Handle error) { | 156 static void UnhandledExceptionCallback(Dart_Handle error) { |
| 156 DCHECK(!Dart_IsError(error)); | 157 DCHECK(!Dart_IsError(error)); |
| 157 LOG(ERROR) << Dart_GetError(error); | 158 LOG(ERROR) << Dart_GetError(error); |
| 158 } | 159 } |
| 159 | 160 |
| 160 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, | 161 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
| 161 Dart_Handle library, | 162 Dart_Handle library, |
| 162 Dart_Handle url) { | 163 Dart_Handle url) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 300 |
| 300 CHECK(Dart_SetVMFlags(argc, argv)); | 301 CHECK(Dart_SetVMFlags(argc, argv)); |
| 301 CHECK(Dart_Initialize(IsolateCreateCallback, | 302 CHECK(Dart_Initialize(IsolateCreateCallback, |
| 302 nullptr, // Isolate interrupt callback. | 303 nullptr, // Isolate interrupt callback. |
| 303 UnhandledExceptionCallback, IsolateShutdownCallback, | 304 UnhandledExceptionCallback, IsolateShutdownCallback, |
| 304 // File IO callbacks. | 305 // File IO callbacks. |
| 305 nullptr, nullptr, nullptr, nullptr, nullptr)); | 306 nullptr, nullptr, nullptr, nullptr, nullptr)); |
| 306 } | 307 } |
| 307 | 308 |
| 308 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |