| 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/core/script/dart_controller.h" | 5 #include "sky/engine/core/script/dart_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void DartController::CreateIsolateFor(PassOwnPtr<DOMDartState> state) { | 124 void DartController::CreateIsolateFor(PassOwnPtr<DOMDartState> state) { |
| 125 CHECK(kDartIsolateSnapshotBuffer); | 125 CHECK(kDartIsolateSnapshotBuffer); |
| 126 char* error = nullptr; | 126 char* error = nullptr; |
| 127 dom_dart_state_ = state; | 127 dom_dart_state_ = state; |
| 128 Dart_Isolate isolate = Dart_CreateIsolate( | 128 Dart_Isolate isolate = Dart_CreateIsolate( |
| 129 dom_dart_state_->url().utf8().data(), "main", kDartIsolateSnapshotBuffer, | 129 dom_dart_state_->url().utf8().data(), "main", kDartIsolateSnapshotBuffer, |
| 130 nullptr, static_cast<DartState*>(dom_dart_state_.get()), &error); | 130 nullptr, static_cast<DartState*>(dom_dart_state_.get()), &error); |
| 131 Dart_SetMessageNotifyCallback(MessageNotifyCallback); | 131 Dart_SetMessageNotifyCallback(MessageNotifyCallback); |
| 132 CHECK(isolate) << error; | 132 CHECK(isolate) << error; |
| 133 dom_dart_state_->SetIsolate(isolate); | 133 dom_dart_state_->SetIsolate(isolate); |
| 134 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); | |
| 135 CHECK(!LogIfError(Dart_SetLibraryTagHandler(DartLibraryTagHandler))); | 134 CHECK(!LogIfError(Dart_SetLibraryTagHandler(DartLibraryTagHandler))); |
| 136 | 135 |
| 137 { | 136 { |
| 138 DartApiScope apiScope; | 137 DartApiScope apiScope; |
| 139 | 138 |
| 140 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 139 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 141 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); | 140 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); |
| 142 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 141 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 143 BuiltinNatives::Init(BuiltinNatives::MainIsolate); | 142 BuiltinNatives::Init(BuiltinNatives::MainIsolate); |
| 144 | 143 |
| 145 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state())); | 144 builtin_sky_ = adoptPtr(new BuiltinSky(dart_state())); |
| 146 dart_state()->class_library().set_provider(builtin_sky_.get()); | 145 dart_state()->class_library().set_provider(builtin_sky_.get()); |
| 147 | 146 |
| 148 if (dart_state()->document()) | 147 if (dart_state()->document()) |
| 149 builtin_sky_->InstallWindow(dart_state()); | 148 builtin_sky_->InstallWindow(dart_state()); |
| 150 | 149 |
| 151 EnsureHandleWatcherStarted(); | 150 EnsureHandleWatcherStarted(); |
| 152 } | 151 } |
| 153 Dart_ExitIsolate(); | 152 Dart_ExitIsolate(); |
| 154 } | 153 } |
| 155 | 154 |
| 156 void DartController::InstallView(View* view) { | 155 void DartController::InstallView(View* view) { |
| 157 DartIsolateScope isolate_scope(dart_state()->isolate()); | 156 DartIsolateScope isolate_scope(dart_state()->isolate()); |
| 158 DartApiScope dart_api_scope; | 157 DartApiScope dart_api_scope; |
| 159 | 158 |
| 160 builtin_sky_->InstallView(view); | 159 builtin_sky_->InstallView(view); |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |