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

Side by Side 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 unified diff | Download patch
« runtime/bin/loader.cc ('K') | « runtime/bin/loader.cc ('k') | 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 (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of vmservice_io; 5 part of vmservice_io;
6 6
7 _sanitizeWindowsPath(path) { 7 _sanitizeWindowsPath(path) {
8 // For Windows we need to massage the paths a bit according to 8 // For Windows we need to massage the paths a bit according to
9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx 9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
10 // 10 //
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 data = 'Could not import "$uri" from "$libraryUrl": $data'; 332 data = 'Could not import "$uri" from "$libraryUrl": $data';
333 } 333 }
334 } 334 }
335 msg[0] = tag; 335 msg[0] = tag;
336 msg[1] = uri.toString(); 336 msg[1] = uri.toString();
337 msg[2] = libraryUrl; 337 msg[2] = libraryUrl;
338 msg[3] = data; 338 msg[3] = data;
339 sp.send(msg); 339 sp.send(msg);
340 } 340 }
341 341
342 // Send a response to the requesting isolate.
343 void _sendExtensionImportResponse(SendPort sp,
344 Uri uri,
345 String libraryUrl,
346 String resolvedUri) {
347 var msg = new List(4);
348 int tag = _Dart_kImportExtension;
349 if (resolvedUri == null) {
350 // We could not resolve the dart-ext: uri.
351 tag = -tag;
352 resolvedUri = 'Could not resolve "$uri" from "$libraryUrl"';
353 }
354 msg[0] = tag;
355 msg[1] = uri.toString();
356 msg[2] = libraryUrl;
357 msg[3] = resolvedUri;
358 sp.send(msg);
359 }
360
342 void _loadHttp(SendPort sp, 361 void _loadHttp(SendPort sp,
343 int tag, 362 int tag,
344 Uri uri, 363 Uri uri,
345 Uri resolvedUri, 364 Uri resolvedUri,
346 String libraryUrl) { 365 String libraryUrl) {
347 if (_httpClient == null) { 366 if (_httpClient == null) {
348 _httpClient = new HttpClient()..maxConnectionsPerHost = 6; 367 _httpClient = new HttpClient()..maxConnectionsPerHost = 6;
349 } 368 }
350 _httpClient.getUrl(resolvedUri) 369 _httpClient.getUrl(resolvedUri)
351 .then((HttpClientRequest request) => request.close()) 370 .then((HttpClientRequest request) => request.close())
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 const _Dart_kScriptTag = 1; // Load the root script. 892 const _Dart_kScriptTag = 1; // Load the root script.
874 const _Dart_kSourceTag = 2; // Load a part source. 893 const _Dart_kSourceTag = 2; // Load a part source.
875 const _Dart_kImportTag = 3; // Import a library. 894 const _Dart_kImportTag = 3; // Import a library.
876 895
877 // Extra requests. Keep these in sync between loader.dart and builtin.dart. 896 // Extra requests. Keep these in sync between loader.dart and builtin.dart.
878 const _Dart_kInitLoader = 4; // Initialize the loader. 897 const _Dart_kInitLoader = 4; // Initialize the loader.
879 const _Dart_kResourceLoad = 5; // Resource class support. 898 const _Dart_kResourceLoad = 5; // Resource class support.
880 const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory. 899 const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
881 const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file. 900 const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
882 const _Dart_kResolvePackageUri = 8; // Resolve a package: uri. 901 const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
902 const _Dart_kImportExtension = 9; // Import a dart-ext: file.
883 903
884 // External entry point for loader requests. 904 // External entry point for loader requests.
885 _processLoadRequest(request) { 905 _processLoadRequest(request) {
886 assert(request is List); 906 assert(request is List);
887 assert(request.length > 4); 907 assert(request.length > 4);
888 908
889 // Should we trace loading? 909 // Should we trace loading?
890 bool traceLoading = request[0]; 910 bool traceLoading = request[0];
891 911
892 // This is the sending isolate's Dart_GetMainPortId(). 912 // This is the sending isolate's Dart_GetMainPortId().
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 resolvedUri = loaderState._resolvePackageUri(uri); 1003 resolvedUri = loaderState._resolvePackageUri(uri);
984 } catch (e, s) { 1004 } catch (e, s) {
985 if (traceLoading) { 1005 if (traceLoading) {
986 _log("Exception ($e) when resolving package URI: $uri"); 1006 _log("Exception ($e) when resolving package URI: $uri");
987 } 1007 }
988 resolvedUri = null; 1008 resolvedUri = null;
989 } 1009 }
990 sp.send(resolvedUri); 1010 sp.send(resolvedUri);
991 }); 1011 });
992 break; 1012 break;
1013 case _Dart_kImportExtension:
1014 Uri uri = Uri.parse(request[4]);
1015 String libraryUri = request[5];
1016 // Strip any filename off of the libraryUri's path.
1017 int index = libraryUri.lastIndexOf('/');
1018 var path;
1019 if (index == -1) {
1020 path = './';
1021 } else {
1022 path = libraryUri.substring(0, index + 1);
1023 }
1024 var pathUri = Uri.parse(path);
1025 switch (pathUri.scheme) {
1026 case '':
1027 case 'file':
1028 _sendExtensionImportResponse(sp, uri, libraryUri,
1029 pathUri.toFilePath());
1030 break;
1031 case 'data':
1032 case 'http':
1033 case 'https':
1034 _sendExtensionImportResponse(sp, uri, libraryUri,
1035 pathUri.toString());
1036 break;
1037 case 'package':
1038 // Start package resolution.
1039 loaderState._triggerPackageResolution(() {
1040 // Attempt to find the fully resolved uri of [path].
1041 Uri resolvedUri;
1042 try {
1043 resolvedUri = loaderState._resolvePackageUri(pathUri);
1044 } catch (e, s) {
1045 if (traceLoading) {
1046 _log("Exception ($e) when resolving package URI: $uri");
1047 }
1048 resolvedUri = null;
1049 }
1050 _sendExtensionImportResponse(sp,
1051 uri,
1052 libraryUri,
1053 resolvedUri.toString());
1054 });
1055 break;
1056 default:
1057 if (traceLoading) {
1058 _log('Unknown scheme (${pathUri.scheme}) in $pathUri.');
1059 }
1060 _sendExtensionImportResponse(sp, uri, libraryUri, null);
1061 break;
1062 }
1063 break;
993 default: 1064 default:
994 _log('Unknown loader request tag=$tag from $isolateId'); 1065 _log('Unknown loader request tag=$tag from $isolateId');
995 } 1066 }
996 } 1067 }
OLDNEW
« 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