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

Unified Diff: sky/engine/core/script/dart_loader.cc

Issue 919883002: Allow sky apps to be consumers of mojo services (Closed) Base URL: https://github.com/eseidel/skydart.git@master
Patch Set: cr comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/script/dart_loader.h ('k') | sky/examples/dart.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/script/dart_loader.cc
diff --git a/sky/engine/core/script/dart_loader.cc b/sky/engine/core/script/dart_loader.cc
index 486f2c8da44a2b48ea250ad68b1abb2258d9386c..4345dda3c099db161affa41fedbc171cf2a83df4 100644
--- a/sky/engine/core/script/dart_loader.cc
+++ b/sky/engine/core/script/dart_loader.cc
@@ -8,12 +8,14 @@
#include "base/callback.h"
#include "mojo/common/data_pipe_drainer.h"
#include "sky/engine/core/script/dart_dependency_catcher.h"
+#include "sky/engine/core/script/dom_dart_state.h"
#include "sky/engine/platform/fetcher/MojoFetcher.h"
#include "sky/engine/platform/weborigin/KURL.h"
#include "sky/engine/tonic/dart_api_scope.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_error.h"
#include "sky/engine/tonic/dart_isolate_scope.h"
+#include "sky/engine/wtf/MainThread.h"
using mojo::common::DataPipeDrainer;
@@ -26,6 +28,10 @@ Dart_Handle CanonicalizeURL(DartState* state,
String string = StringFromDart(url);
if (string.startsWith("dart:"))
return url;
+ // TODO(dart): Figure out how 'package:' should work in sky.
+ if (string.startsWith("package:")) {
+ string.replace("package:", "/gen/");
+ }
String library_url_string = StringFromDart(Dart_LibraryUrl(library));
KURL library_url = KURL(ParsedURLString, library_url_string);
KURL resolved_url = KURL(library_url, string);
@@ -181,11 +187,15 @@ Dart_Handle DartLoader::HandleLibraryTag(Dart_LibraryTag tag,
DCHECK(Dart_IsLibrary(library));
DCHECK(Dart_IsString(url));
if (tag == Dart_kCanonicalizeUrl)
- return CanonicalizeURL(dart_state_.get(), library, url);
- if (tag == Dart_kImportTag)
- return Import(library, url);
- if (tag == Dart_kSourceTag)
- return Source(library, url);
+ return CanonicalizeURL(DartState::Current(), library, url);
+ if (tag == Dart_kImportTag) {
+ CHECK(WTF::isMainThread());
+ return DOMDartState::Current()->loader().Import(library, url);
+ }
+ if (tag == Dart_kSourceTag) {
+ CHECK(WTF::isMainThread());
+ return DOMDartState::Current()->loader().Source(library, url);
+ }
DCHECK(false);
return Dart_NewApiError("Unknown library tag.");
}
« no previous file with comments | « sky/engine/core/script/dart_loader.h ('k') | sky/examples/dart.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698