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

Side by Side Diff: runtime/bin/builtin.dart

Issue 543713002: Reduce the number of Uris parsed in builtin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library builtin; 5 library builtin;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 // import 'root_library'; happens here from C Code 9 // import 'root_library'; happens here from C Code
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Returns either a file path or a URI starting with http:, as a String. 165 // Returns either a file path or a URI starting with http:, as a String.
166 String _filePathFromUri(String userUri) { 166 String _filePathFromUri(String userUri) {
167 var uri = Uri.parse(userUri); 167 var uri = Uri.parse(userUri);
168 _logResolution('# Getting file path from: $uri'); 168 _logResolution('# Getting file path from: $uri');
169 169
170 var path; 170 var path;
171 switch (uri.scheme) { 171 switch (uri.scheme) {
172 case '': 172 case '':
173 case 'file': 173 case 'file':
174 return uri.toFilePath(); 174 return uri.toFilePath();
175 break;
176 case 'package': 175 case 'package':
177 return _filePathFromPackageUri(uri); 176 return _filePathFromPackageUri(uri);
178 break;
179 case 'http': 177 case 'http':
180 return uri.toString(); 178 return uri.toString();
181 default: 179 default:
182 // Only handling file, http, and package URIs 180 // Only handling file, http, and package URIs
183 // in standalone binary. 181 // in standalone binary.
184 _logResolution('# Unknown scheme (${uri.scheme}) in $uri.'); 182 _logResolution('# Unknown scheme (${uri.scheme}) in $uri.');
185 throw 'Not a known scheme: $uri'; 183 throw 'Not a known scheme: $uri';
186 } 184 }
187 } 185 }
188 186
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 _logResolution("_asyncLoadError($uri), error: $error"); 273 _logResolution("_asyncLoadError($uri), error: $error");
276 _numOutstandingLoadRequests--; 274 _numOutstandingLoadRequests--;
277 _asyncLoadErrorCallback(uri, libraryUri, error); 275 _asyncLoadErrorCallback(uri, libraryUri, error);
278 if (_numOutstandingLoadRequests == 0) { 276 if (_numOutstandingLoadRequests == 0) {
279 _signalDoneLoading(); 277 _signalDoneLoading();
280 _cleanup(); 278 _cleanup();
281 } 279 }
282 } 280 }
283 281
284 282
283 // Create a Uri of 'userUri'. Is the input uri is a package uri, the package uri
Ivan Posva 2014/09/04 15:33:18 If the input uri ..., then the package ...
Anders Johnsen 2014/09/05 05:33:24 Done.
284 // is resolved.
285 Uri _createUri(String userUri) {
286 var uri = Uri.parse(userUri);
287 _logResolution('# Creating uri for: $uri');
288
289 switch (uri.scheme) {
290 case '':
291 case 'file':
292 case 'http':
293 return uri;
294 case 'package':
295 return Uri.parse(_filePathFromPackageUri(uri));
296 default:
297 // Only handling file, http, and package URIs
298 // in standalone binary.
299 _logResolution('# Unknown scheme (${uri.scheme}) in $uri.');
300 throw 'Not a known scheme: $uri';
301 }
302 }
303
304
285 // Asynchronously loads script data through a http or file uri. 305 // Asynchronously loads script data through a http or file uri.
286 _loadDataAsync(int tag, String uri, String libraryUri) { 306 _loadDataAsync(int tag, String uri, String libraryUri) {
287 var filePath;
288 Uri sourceUri;
289 if (tag == null) { 307 if (tag == null) {
290 uri = _resolveScriptUri(uri); 308 uri = _resolveScriptUri(uri);
291 sourceUri = Uri.parse(uri);
292 filePath = _filePathFromUri(uri);
293 } else {
294 filePath = _filePathFromUri(uri);
295 sourceUri = Uri.parse(filePath);
296 } 309 }
310 Uri resourceUri = _createUri(uri);
297 _numOutstandingLoadRequests++; 311 _numOutstandingLoadRequests++;
298 _logResolution("_loadDataAsync($uri), " 312 _logResolution("_loadDataAsync($uri), "
299 "${_numOutstandingLoadRequests} requests outstanding"); 313 "${_numOutstandingLoadRequests} requests outstanding");
300 if (sourceUri.scheme == 'http') { 314 if (resourceUri.scheme == 'http') {
301 _httpGet(sourceUri, libraryUri, (data) { 315 _httpGet(resourceUri, libraryUri, (data) {
302 _loadScript(tag, uri, libraryUri, data); 316 _loadScript(tag, uri, libraryUri, data);
303 }); 317 });
304 } else { 318 } else {
305 var sourceFile = new File(filePath); 319 var sourceFile = new File(resourceUri.toFilePath());
306 sourceFile.readAsBytes().then((data) { 320 sourceFile.readAsBytes().then((data) {
307 _loadScript(tag, uri, libraryUri, data); 321 _loadScript(tag, uri, libraryUri, data);
308 }, 322 },
309 onError: (e) { 323 onError: (e) {
310 _asyncLoadError(uri, libraryUri, e); 324 _asyncLoadError(uri, libraryUri, e);
311 }); 325 });
312 } 326 }
313 } 327 }
314 328
315 // Returns the directory part, the filename part, and the name 329 // Returns the directory part, the filename part, and the name
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } else if (Platform.isWindows) { 364 } else if (Platform.isWindows) {
351 filename = '$name.dll'; 365 filename = '$name.dll';
352 } else { 366 } else {
353 _logResolution( 367 _logResolution(
354 'Native extensions not supported on ${Platform.operatingSystem}'); 368 'Native extensions not supported on ${Platform.operatingSystem}');
355 throw 'Native extensions not supported on ${Platform.operatingSystem}'; 369 throw 'Native extensions not supported on ${Platform.operatingSystem}';
356 } 370 }
357 371
358 return [path, filename, name]; 372 return [path, filename, name];
359 } 373 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698