| 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/tonic/dart_library_loader.h" | 5 #include "sky/engine/tonic/dart_library_loader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "mojo/common/data_pipe_drainer.h" | 9 #include "mojo/common/data_pipe_drainer.h" |
| 10 #include "sky/engine/tonic/dart_api_scope.h" | 10 #include "sky/engine/tonic/dart_api_scope.h" |
| 11 #include "sky/engine/tonic/dart_converter.h" | 11 #include "sky/engine/tonic/dart_converter.h" |
| 12 #include "sky/engine/tonic/dart_dependency_catcher.h" | 12 #include "sky/engine/tonic/dart_dependency_catcher.h" |
| 13 #include "sky/engine/tonic/dart_error.h" | 13 #include "sky/engine/tonic/dart_error.h" |
| 14 #include "sky/engine/tonic/dart_isolate_scope.h" | 14 #include "sky/engine/tonic/dart_isolate_scope.h" |
| 15 #include "sky/engine/tonic/dart_library_provider.h" | 15 #include "sky/engine/tonic/dart_library_provider.h" |
| 16 #include "sky/engine/tonic/dart_state.h" | 16 #include "sky/engine/tonic/dart_state.h" |
| 17 #include "sky/engine/wtf/MainThread.h" | |
| 18 | 17 |
| 19 using mojo::common::DataPipeDrainer; | 18 using mojo::common::DataPipeDrainer; |
| 20 | 19 |
| 21 namespace blink { | 20 namespace blink { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 // Helper to erase a T* from a container of std::unique_ptr<T>s. | 24 // Helper to erase a T* from a container of std::unique_ptr<T>s. |
| 26 template<typename T, typename C> | 25 template<typename T, typename C> |
| 27 void EraseUniquePtr(C& container, T* item) { | 26 void EraseUniquePtr(C& container, T* item) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 192 } |
| 194 | 193 |
| 195 Dart_Handle DartLibraryLoader::HandleLibraryTag(Dart_LibraryTag tag, | 194 Dart_Handle DartLibraryLoader::HandleLibraryTag(Dart_LibraryTag tag, |
| 196 Dart_Handle library, | 195 Dart_Handle library, |
| 197 Dart_Handle url) { | 196 Dart_Handle url) { |
| 198 DCHECK(Dart_IsLibrary(library)); | 197 DCHECK(Dart_IsLibrary(library)); |
| 199 DCHECK(Dart_IsString(url)); | 198 DCHECK(Dart_IsString(url)); |
| 200 if (tag == Dart_kCanonicalizeUrl) | 199 if (tag == Dart_kCanonicalizeUrl) |
| 201 return DartState::Current()->library_loader().CanonicalizeURL(library, url); | 200 return DartState::Current()->library_loader().CanonicalizeURL(library, url); |
| 202 if (tag == Dart_kImportTag) { | 201 if (tag == Dart_kImportTag) { |
| 203 CHECK(WTF::isMainThread()); | |
| 204 return DartState::Current()->library_loader().Import(library, url); | 202 return DartState::Current()->library_loader().Import(library, url); |
| 205 } | 203 } |
| 206 if (tag == Dart_kSourceTag) { | 204 if (tag == Dart_kSourceTag) { |
| 207 CHECK(WTF::isMainThread()); | |
| 208 return DartState::Current()->library_loader().Source(library, url); | 205 return DartState::Current()->library_loader().Source(library, url); |
| 209 } | 206 } |
| 210 DCHECK(false); | 207 DCHECK(false); |
| 211 return Dart_NewApiError("Unknown library tag."); | 208 return Dart_NewApiError("Unknown library tag."); |
| 212 } | 209 } |
| 213 | 210 |
| 214 void DartLibraryLoader::WaitForDependencies( | 211 void DartLibraryLoader::WaitForDependencies( |
| 215 const std::unordered_set<DartDependency*>& dependencies, | 212 const std::unordered_set<DartDependency*>& dependencies, |
| 216 const base::Closure& callback) { | 213 const base::Closure& callback) { |
| 217 if (dependencies.empty()) | 214 if (dependencies.empty()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 296 |
| 300 WatcherSignaler watcher_signaler(*this, job); | 297 WatcherSignaler watcher_signaler(*this, job); |
| 301 | 298 |
| 302 LOG(ERROR) << "Library Load failed: " << job->name(); | 299 LOG(ERROR) << "Library Load failed: " << job->name(); |
| 303 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? | 300 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? |
| 304 | 301 |
| 305 EraseUniquePtr<Job>(jobs_, job); | 302 EraseUniquePtr<Job>(jobs_, job); |
| 306 } | 303 } |
| 307 | 304 |
| 308 } // namespace blink | 305 } // namespace blink |
| OLD | NEW |