Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: sky/engine/core/script/dart_loader.cc

Issue 1130353009: Teach SkyView how to load the main script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/trace_event/trace_event.h"
10 #include "mojo/common/data_pipe_drainer.h" 10 #include "mojo/common/data_pipe_drainer.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 void DartLoader::WaitForDependencies( 225 void DartLoader::WaitForDependencies(
226 const HashSet<DartDependency*>& dependencies, 226 const HashSet<DartDependency*>& dependencies,
227 const base::Closure& callback) { 227 const base::Closure& callback) {
228 if (dependencies.isEmpty()) 228 if (dependencies.isEmpty())
229 return callback.Run(); 229 return callback.Run();
230 dependency_watchers_.add( 230 dependency_watchers_.add(
231 adoptPtr(new DependencyWatcher(dependencies, callback))); 231 adoptPtr(new DependencyWatcher(dependencies, callback)));
232 } 232 }
233 233
234 Dart_Handle DartLoader::Import(Dart_Handle library, Dart_Handle url) { 234 void DartLoader::LoadLibrary(const KURL& url) {
235 KURL parsed_url(ParsedURLString, StringFromDart(url)); 235 const auto& result = pending_libraries_.add(url.string(), nullptr);
236 const auto& result = pending_libraries_.add(parsed_url.string(), nullptr);
237 if (result.isNewEntry) { 236 if (result.isNewEntry) {
238 OwnPtr<Job> job = adoptPtr(new ImportJob(this, parsed_url)); 237 OwnPtr<Job> job = adoptPtr(new ImportJob(this, url));
239 result.storedValue->value = job.get(); 238 result.storedValue->value = job.get();
240 jobs_.add(job.release()); 239 jobs_.add(job.release());
241 } 240 }
242 if (dependency_catcher_) 241 if (dependency_catcher_)
243 dependency_catcher_->AddDependency(result.storedValue->value); 242 dependency_catcher_->AddDependency(result.storedValue->value);
243 }
244
245 Dart_Handle DartLoader::Import(Dart_Handle library, Dart_Handle url) {
246 LoadLibrary(KURL(ParsedURLString, StringFromDart(url)));
244 return Dart_True(); 247 return Dart_True();
245 } 248 }
246 249
247 Dart_Handle DartLoader::Source(Dart_Handle library, Dart_Handle url) { 250 Dart_Handle DartLoader::Source(Dart_Handle library, Dart_Handle url) {
248 KURL parsed_url(ParsedURLString, StringFromDart(url)); 251 KURL parsed_url(ParsedURLString, StringFromDart(url));
249 OwnPtr<Job> job = adoptPtr(new SourceJob(this, parsed_url, library)); 252 OwnPtr<Job> job = adoptPtr(new SourceJob(this, parsed_url, library));
250 if (dependency_catcher_) 253 if (dependency_catcher_)
251 dependency_catcher_->AddDependency(job.get()); 254 dependency_catcher_->AddDependency(job.get());
252 jobs_.add(job.release()); 255 jobs_.add(job.release());
253 return Dart_True(); 256 return Dart_True();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 296
294 WatcherSignaler watcher_signaler(*this, job); 297 WatcherSignaler watcher_signaler(*this, job);
295 298
296 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data(); 299 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data();
297 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? 300 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case?
298 301
299 jobs_.remove(job); 302 jobs_.remove(job);
300 } 303 }
301 304
302 } // namespace blink 305 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698