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

Unified Diff: runtime/bin/vmservice/loader.dart

Issue 2146093002: Support loading dart-ext from within a package when using a package map (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self review Created 4 years, 5 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
« runtime/bin/loader.cc ('K') | « runtime/bin/loader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/loader.dart
diff --git a/runtime/bin/vmservice/loader.dart b/runtime/bin/vmservice/loader.dart
index cb6792ba5bedeefa69de0c829bfd60919b3f3088..7686f1c41f37d0d3307caeb4786fdad59525ad6b 100644
--- a/runtime/bin/vmservice/loader.dart
+++ b/runtime/bin/vmservice/loader.dart
@@ -339,6 +339,25 @@ void _sendResourceResponse(SendPort sp,
sp.send(msg);
}
+// Send a response to the requesting isolate.
+void _sendExtensionImportResponse(SendPort sp,
+ Uri uri,
+ String libraryUrl,
+ String resolvedUri) {
+ var msg = new List(4);
+ int tag = _Dart_kImportExtension;
+ if (resolvedUri == null) {
+ // We could not resolve the dart-ext: uri.
+ tag = -tag;
+ resolvedUri = 'Could not resolve "$uri" from "$libraryUrl"';
+ }
+ msg[0] = tag;
+ msg[1] = uri.toString();
+ msg[2] = libraryUrl;
+ msg[3] = resolvedUri;
+ sp.send(msg);
+}
+
void _loadHttp(SendPort sp,
int tag,
Uri uri,
@@ -880,6 +899,7 @@ const _Dart_kResourceLoad = 5; // Resource class support.
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
+const _Dart_kImportExtension = 9; // Import a dart-ext: file.
// External entry point for loader requests.
_processLoadRequest(request) {
@@ -990,6 +1010,57 @@ _processLoadRequest(request) {
sp.send(resolvedUri);
});
break;
+ case _Dart_kImportExtension:
+ Uri uri = Uri.parse(request[4]);
+ String libraryUri = request[5];
+ // Strip any filename off of the libraryUri's path.
+ int index = libraryUri.lastIndexOf('/');
+ var path;
+ if (index == -1) {
+ path = './';
+ } else {
+ path = libraryUri.substring(0, index + 1);
+ }
+ var pathUri = Uri.parse(path);
+ switch (pathUri.scheme) {
+ case '':
+ case 'file':
+ _sendExtensionImportResponse(sp, uri, libraryUri,
+ pathUri.toFilePath());
+ break;
+ case 'data':
+ case 'http':
+ case 'https':
+ _sendExtensionImportResponse(sp, uri, libraryUri,
+ pathUri.toString());
+ break;
+ case 'package':
+ // Start package resolution.
+ loaderState._triggerPackageResolution(() {
+ // Attempt to find the fully resolved uri of [path].
+ Uri resolvedUri;
+ try {
+ resolvedUri = loaderState._resolvePackageUri(pathUri);
+ } catch (e, s) {
+ if (traceLoading) {
+ _log("Exception ($e) when resolving package URI: $uri");
+ }
+ resolvedUri = null;
+ }
+ _sendExtensionImportResponse(sp,
+ uri,
+ libraryUri,
+ resolvedUri.toString());
+ });
+ break;
+ default:
+ if (traceLoading) {
+ _log('Unknown scheme (${pathUri.scheme}) in $pathUri.');
+ }
+ _sendExtensionImportResponse(sp, uri, libraryUri, null);
+ break;
+ }
+ break;
default:
_log('Unknown loader request tag=$tag from $isolateId');
}
« runtime/bin/loader.cc ('K') | « runtime/bin/loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698