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_loader.h" | 6 #include "sky/engine/core/script/dart_loader.h" |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/trace_event/trace_event.h" |
9 #include "mojo/common/data_pipe_drainer.h" | 10 #include "mojo/common/data_pipe_drainer.h" |
10 #include "sky/engine/core/script/dart_dependency_catcher.h" | 11 #include "sky/engine/core/script/dart_dependency_catcher.h" |
11 #include "sky/engine/core/script/dom_dart_state.h" | 12 #include "sky/engine/core/script/dom_dart_state.h" |
12 #include "sky/engine/platform/fetcher/MojoFetcher.h" | 13 #include "sky/engine/platform/fetcher/MojoFetcher.h" |
13 #include "sky/engine/platform/weborigin/KURL.h" | 14 #include "sky/engine/platform/weborigin/KURL.h" |
14 #include "sky/engine/tonic/dart_api_scope.h" | 15 #include "sky/engine/tonic/dart_api_scope.h" |
15 #include "sky/engine/tonic/dart_converter.h" | 16 #include "sky/engine/tonic/dart_converter.h" |
16 #include "sky/engine/tonic/dart_error.h" | 17 #include "sky/engine/tonic/dart_error.h" |
17 #include "sky/engine/tonic/dart_isolate_scope.h" | 18 #include "sky/engine/tonic/dart_isolate_scope.h" |
18 #include "sky/engine/wtf/MainThread.h" | 19 #include "sky/engine/wtf/MainThread.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 73 } |
73 // Subclasses must implement OnDataComplete. | 74 // Subclasses must implement OnDataComplete. |
74 | 75 |
75 KURL url_; | 76 KURL url_; |
76 MojoFetcher fetcher_; | 77 MojoFetcher fetcher_; |
77 OwnPtr<DataPipeDrainer> drainer_; | 78 OwnPtr<DataPipeDrainer> drainer_; |
78 }; | 79 }; |
79 | 80 |
80 class DartLoader::ImportJob : public Job { | 81 class DartLoader::ImportJob : public Job { |
81 public: | 82 public: |
82 using Job::Job; | 83 ImportJob(DartLoader* loader, const KURL& url) |
| 84 : Job(loader, url) { |
| 85 TRACE_EVENT_ASYNC_BEGIN1("sky", "DartLoader::ImportJob", this, |
| 86 "url", url.string().ascii().toStdString()); |
| 87 } |
83 | 88 |
84 private: | 89 private: |
85 // DataPipeDrainer::Client | 90 // DataPipeDrainer::Client |
86 void OnDataComplete() override { | 91 void OnDataComplete() override { |
| 92 TRACE_EVENT_ASYNC_END0("sky", "DartLoader::ImportJob", this); |
87 loader_->DidCompleteImportJob(this, buffer_); | 93 loader_->DidCompleteImportJob(this, buffer_); |
88 } | 94 } |
89 }; | 95 }; |
90 | 96 |
91 class DartLoader::SourceJob : public Job { | 97 class DartLoader::SourceJob : public Job { |
92 public: | 98 public: |
93 SourceJob(DartLoader* loader, const KURL& url, Dart_Handle library) | 99 SourceJob(DartLoader* loader, const KURL& url, Dart_Handle library) |
94 : Job(loader, url), library_(loader->dart_state(), library) {} | 100 : Job(loader, url), library_(loader->dart_state(), library) { |
| 101 TRACE_EVENT_ASYNC_BEGIN1("sky", "DartLoader::SourceJob", this, |
| 102 "url", url.string().ascii().toStdString()); |
| 103 } |
95 | 104 |
96 Dart_PersistentHandle library() const { return library_.value(); } | 105 Dart_PersistentHandle library() const { return library_.value(); } |
97 | 106 |
98 private: | 107 private: |
99 // DataPipeDrainer::Client | 108 // DataPipeDrainer::Client |
100 void OnDataComplete() override { | 109 void OnDataComplete() override { |
| 110 TRACE_EVENT_ASYNC_END0("sky", "DartLoader::SourceJob", this); |
101 loader_->DidCompleteSourceJob(this, buffer_); | 111 loader_->DidCompleteSourceJob(this, buffer_); |
102 } | 112 } |
103 | 113 |
104 DartPersistentValue library_; | 114 DartPersistentValue library_; |
105 }; | 115 }; |
106 | 116 |
107 // A DependencyWatcher represents a request to watch for when a given set of | 117 // A DependencyWatcher represents a request to watch for when a given set of |
108 // dependencies (either libraries or parts of libraries) have finished loading. | 118 // dependencies (either libraries or parts of libraries) have finished loading. |
109 // When the dependencies are satisfied (including transitive dependencies), then | 119 // When the dependencies are satisfied (including transitive dependencies), then |
110 // the |callback| will be invoked. | 120 // the |callback| will be invoked. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 293 |
284 WatcherSignaler watcher_signaler(*this, job); | 294 WatcherSignaler watcher_signaler(*this, job); |
285 | 295 |
286 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data(); | 296 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data(); |
287 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? | 297 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? |
288 | 298 |
289 jobs_.remove(job); | 299 jobs_.remove(job); |
290 } | 300 } |
291 | 301 |
292 } // namespace blink | 302 } // namespace blink |
OLD | NEW |