| 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" | 17 #include "sky/engine/wtf/MainThread.h" |
| 18 | 18 |
| 19 using mojo::common::DataPipeDrainer; | 19 using mojo::common::DataPipeDrainer; |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 // Helper to erase a T* from a container of std::unique_ptr<T>s. | 24 |
| 25 template<typename T, typename C> | 25 // Helper to erase a T* from a container of std::unique_ptr<T>s. |
| 26 void EraseUniquePtr(C& container, T* item) { | 26 template<typename T, typename C> |
| 27 std::unique_ptr<T> key = std::unique_ptr<T>(item); | 27 void EraseUniquePtr(C& container, T* item) { |
| 28 container.erase(key); | 28 std::unique_ptr<T> key = std::unique_ptr<T>(item); |
| 29 key.release(); | 29 container.erase(key); |
| 30 } | 30 key.release(); |
| 31 } |
| 32 |
| 31 } | 33 } |
| 32 | 34 |
| 33 // A DartLibraryLoader::Job represents a network load. It fetches data from the | 35 // A DartLibraryLoader::Job represents a network load. It fetches data from the |
| 34 // network and buffers the data in std::vector. To cancel the job, delete this | 36 // network and buffers the data in std::vector. To cancel the job, delete this |
| 35 // object. | 37 // object. |
| 36 class DartLibraryLoader::Job : public DartDependency, | 38 class DartLibraryLoader::Job : public DartDependency, |
| 37 public DataPipeDrainer::Client { | 39 public DataPipeDrainer::Client { |
| 38 public: | 40 public: |
| 39 Job(DartLibraryLoader* loader, const std::string& name) | 41 Job(DartLibraryLoader* loader, const std::string& name) |
| 40 : loader_(loader), name_(name), weak_factory_(this) { | 42 : loader_(loader), name_(name), weak_factory_(this) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 299 |
| 298 WatcherSignaler watcher_signaler(*this, job); | 300 WatcherSignaler watcher_signaler(*this, job); |
| 299 | 301 |
| 300 LOG(ERROR) << "Library Load failed: " << job->name(); | 302 LOG(ERROR) << "Library Load failed: " << job->name(); |
| 301 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? | 303 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? |
| 302 | 304 |
| 303 EraseUniquePtr<Job>(jobs_, job); | 305 EraseUniquePtr<Job>(jobs_, job); |
| 304 } | 306 } |
| 305 | 307 |
| 306 } // namespace blink | 308 } // namespace blink |
| OLD | NEW |