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

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

Issue 1192743011: Remove support for "mojo:" libraries (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "sky/engine/core/script/dart_dependency_catcher.h" 11 #include "sky/engine/core/script/dart_dependency_catcher.h"
12 #include "sky/engine/core/script/dom_dart_state.h" 12 #include "sky/engine/core/script/dom_dart_state.h"
13 #include "sky/engine/platform/fetcher/MojoFetcher.h" 13 #include "sky/engine/platform/fetcher/MojoFetcher.h"
14 #include "sky/engine/platform/weborigin/KURL.h" 14 #include "sky/engine/platform/weborigin/KURL.h"
15 #include "sky/engine/tonic/dart_api_scope.h" 15 #include "sky/engine/tonic/dart_api_scope.h"
16 #include "sky/engine/tonic/dart_converter.h" 16 #include "sky/engine/tonic/dart_converter.h"
17 #include "sky/engine/tonic/dart_error.h" 17 #include "sky/engine/tonic/dart_error.h"
18 #include "sky/engine/tonic/dart_isolate_scope.h" 18 #include "sky/engine/tonic/dart_isolate_scope.h"
19 #include "sky/engine/wtf/MainThread.h" 19 #include "sky/engine/wtf/MainThread.h"
20 20
21 using mojo::common::DataPipeDrainer; 21 using mojo::common::DataPipeDrainer;
22 22
23 namespace blink { 23 namespace blink {
24 namespace { 24 namespace {
25 25
26 Dart_Handle CanonicalizeURL(DartState* state, 26 Dart_Handle CanonicalizeURL(DartState* state,
27 Dart_Handle library, 27 Dart_Handle library,
28 Dart_Handle url) { 28 Dart_Handle url) {
29 String string = StringFromDart(url); 29 String string = StringFromDart(url);
30 if (string.startsWith("dart:") || string.startsWith("mojo:")) 30 if (string.startsWith("dart:"))
31 return url; 31 return url;
32 // TODO(dart): Figure out how 'package:' should work in sky. 32 // TODO(dart): Figure out how 'package:' should work in sky.
33 if (string.startsWith("package:")) { 33 if (string.startsWith("package:")) {
34 string.replace("package:", "/packages/"); 34 string.replace("package:", "/packages/");
35 } 35 }
36 String library_url_string = StringFromDart(Dart_LibraryUrl(library)); 36 String library_url_string = StringFromDart(Dart_LibraryUrl(library));
37 KURL library_url = KURL(ParsedURLString, library_url_string); 37 KURL library_url = KURL(ParsedURLString, library_url_string);
38 KURL resolved_url = KURL(library_url, string); 38 KURL resolved_url = KURL(library_url, string);
39 return StringToDart(state, resolved_url.string()); 39 return StringToDart(state, resolved_url.string());
40 } 40 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 Dart_Handle DartLoader::HandleLibraryTag(Dart_LibraryTag tag, 205 Dart_Handle DartLoader::HandleLibraryTag(Dart_LibraryTag tag,
206 Dart_Handle library, 206 Dart_Handle library,
207 Dart_Handle url) { 207 Dart_Handle url) {
208 DCHECK(Dart_IsLibrary(library)); 208 DCHECK(Dart_IsLibrary(library));
209 DCHECK(Dart_IsString(url)); 209 DCHECK(Dart_IsString(url));
210 if (tag == Dart_kCanonicalizeUrl) 210 if (tag == Dart_kCanonicalizeUrl)
211 return CanonicalizeURL(DartState::Current(), library, url); 211 return CanonicalizeURL(DartState::Current(), library, url);
212 if (tag == Dart_kImportTag) { 212 if (tag == Dart_kImportTag) {
213 CHECK(WTF::isMainThread()); 213 CHECK(WTF::isMainThread());
214
215 String string = StringFromDart(url);
216 if (string.startsWith("mojo:")) {
217 Dart_Handle mojo_library = Dart_LookupLibrary(url);
218 LogIfError(mojo_library);
219 return mojo_library;
220 }
221
222 return DOMDartState::Current()->loader().Import(library, url); 214 return DOMDartState::Current()->loader().Import(library, url);
223 } 215 }
224 if (tag == Dart_kSourceTag) { 216 if (tag == Dart_kSourceTag) {
225 CHECK(WTF::isMainThread()); 217 CHECK(WTF::isMainThread());
226 return DOMDartState::Current()->loader().Source(library, url); 218 return DOMDartState::Current()->loader().Source(library, url);
227 } 219 }
228 DCHECK(false); 220 DCHECK(false);
229 return Dart_NewApiError("Unknown library tag."); 221 return Dart_NewApiError("Unknown library tag.");
230 } 222 }
231 223
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 300
309 WatcherSignaler watcher_signaler(*this, job); 301 WatcherSignaler watcher_signaler(*this, job);
310 302
311 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data(); 303 LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data();
312 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? 304 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case?
313 305
314 jobs_.remove(job); 306 jobs_.remove(job);
315 } 307 }
316 308
317 } // namespace blink 309 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698