OLD | NEW |
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 // NOTE: Do not import 'dart:io' in builtin. | 6 // NOTE: Do not import 'dart:io' in builtin. |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:_internal'; | 9 import 'dart:_internal'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 if (tag == _Dart_kScriptTag) { | 684 if (tag == _Dart_kScriptTag) { |
685 resourceUri = _resolveScriptUri(uri); | 685 resourceUri = _resolveScriptUri(uri); |
686 uri = resourceUri.toString(); | 686 uri = resourceUri.toString(); |
687 } else { | 687 } else { |
688 resourceUri = Uri.parse(uri); | 688 resourceUri = Uri.parse(uri); |
689 } | 689 } |
690 _loadData(tag, uri, resourceUri, libraryUri); | 690 _loadData(tag, uri, resourceUri, libraryUri); |
691 } | 691 } |
692 | 692 |
693 | 693 |
| 694 // Embedder Entrypoint: |
| 695 // Function called by standalone embedder to resolve uris when the VM requests |
| 696 // Dart_kCanonicalizeUrl from the tag handler. |
| 697 String _resolveUri(String base, String userString) { |
| 698 if (!_setupCompleted) { |
| 699 _setupHooks(); |
| 700 } |
| 701 |
| 702 if (_traceLoading) { |
| 703 _log('Resolving: $userString from $base'); |
| 704 } |
| 705 |
| 706 var baseUri = Uri.parse(base); |
| 707 var result = baseUri.resolve(userString).toString(); |
| 708 if (_traceLoading) { |
| 709 _log('Resolved $userString in $base to $result'); |
| 710 } |
| 711 |
| 712 return result; |
| 713 } |
| 714 |
| 715 |
| 716 |
694 // Handling of access to the package root or package map from user code. | 717 // Handling of access to the package root or package map from user code. |
695 _triggerPackageResolution(action) { | 718 _triggerPackageResolution(action) { |
696 if (_packagesReady) { | 719 if (_packagesReady) { |
697 // Packages are ready. Execute the action now. | 720 // Packages are ready. Execute the action now. |
698 action(); | 721 action(); |
699 } else { | 722 } else { |
700 if (_pendingPackageLoads.isEmpty) { | 723 if (_pendingPackageLoads.isEmpty) { |
701 // Package resolution has not been setup yet, and this is the first | 724 // Package resolution has not been setup yet, and this is the first |
702 // request for package resolution & loading. | 725 // request for package resolution & loading. |
703 _requestPackagesMap(); | 726 _requestPackagesMap(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 876 |
854 // Register callbacks and hooks with the rest of the core libraries. | 877 // Register callbacks and hooks with the rest of the core libraries. |
855 _setupHooks() { | 878 _setupHooks() { |
856 _setupCompleted = true; | 879 _setupCompleted = true; |
857 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; | 880 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; |
858 | 881 |
859 VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture; | 882 VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture; |
860 VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture; | 883 VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture; |
861 VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture; | 884 VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture; |
862 } | 885 } |
OLD | NEW |