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

Side by Side Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 429883002: Remove support for the DeferredLibrary annotation and remove tests of it (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Deprecated until sdk 1.8 remove cruft from unused DeferredLibrary 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 | « sdk/lib/_internal/lib/async_patch.dart ('k') | sdk/lib/async/deferred_load.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 _js_helper; 5 library _js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:_isolate_helper' show 8 import 'dart:_isolate_helper' show
9 IsolateNatives, 9 IsolateNatives,
10 leaveJsAsync, 10 leaveJsAsync,
(...skipping 3213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3224 3224
3225 typedef Future<Null> LoadLibraryFunctionType(); 3225 typedef Future<Null> LoadLibraryFunctionType();
3226 3226
3227 LoadLibraryFunctionType _loadLibraryWrapper(String loadId) { 3227 LoadLibraryFunctionType _loadLibraryWrapper(String loadId) {
3228 return () => loadDeferredLibrary(loadId); 3228 return () => loadDeferredLibrary(loadId);
3229 } 3229 }
3230 3230
3231 final Map<String, Future<Null>> _loadingLibraries = <String, Future<Null>>{}; 3231 final Map<String, Future<Null>> _loadingLibraries = <String, Future<Null>>{};
3232 final Set<String> _loadedLibraries = new Set<String>(); 3232 final Set<String> _loadedLibraries = new Set<String>();
3233 3233
3234 Future<Null> loadDeferredLibrary(String loadId, [String uri]) { 3234 Future<Null> loadDeferredLibrary(String loadId) {
3235 List<List<String>> hunkLists = JS('JSExtendableArray|Null', 3235 List<List<String>> hunkLists = JS('JSExtendableArray|Null',
3236 '\$.libraries_to_load[#]', loadId); 3236 '\$.libraries_to_load[#]', loadId);
3237 if (hunkLists == null) return new Future.value(null); 3237 if (hunkLists == null) return new Future.value(null);
3238 3238
3239 return Future.forEach(hunkLists, (hunkNames) { 3239 return Future.forEach(hunkLists, (hunkNames) {
3240 Iterable<Future<Null>> allLoads = 3240 Iterable<Future<Null>> allLoads =
3241 hunkNames.map((hunkName) => _loadHunk(hunkName, uri)); 3241 hunkNames.map((hunkName) => _loadHunk(hunkName));
3242 return Future.wait(allLoads).then((_) => null); 3242 return Future.wait(allLoads).then((_) => null);
3243 }).then((_) => _loadedLibraries.add(loadId)); 3243 }).then((_) => _loadedLibraries.add(loadId));
3244 } 3244 }
3245 3245
3246 Future<Null> _loadHunk(String hunkName, String uri) { 3246 Future<Null> _loadHunk(String hunkName) {
3247 // TODO(ahe): Validate libraryName. Kasper points out that you want 3247 // TODO(ahe): Validate libraryName. Kasper points out that you want
3248 // to be able to experiment with the effect of toggling @DeferLoad, 3248 // to be able to experiment with the effect of toggling @DeferLoad,
3249 // so perhaps we should silently ignore "bad" library names. 3249 // so perhaps we should silently ignore "bad" library names.
3250 Future<Null> future = _loadingLibraries[hunkName]; 3250 Future<Null> future = _loadingLibraries[hunkName];
3251 if (future != null) { 3251 if (future != null) {
3252 return future.then((_) => null); 3252 return future.then((_) => null);
3253 } 3253 }
3254 3254
3255 if (uri == null) { 3255 String uri = IsolateNatives.thisScript;
3256 uri = IsolateNatives.thisScript; 3256
3257 }
3258 int index = uri.lastIndexOf('/'); 3257 int index = uri.lastIndexOf('/');
3259 uri = '${uri.substring(0, index + 1)}$hunkName'; 3258 uri = '${uri.substring(0, index + 1)}$hunkName';
3260 3259
3261 if (Primitives.isJsshell || Primitives.isD8) { 3260 if (Primitives.isJsshell || Primitives.isD8) {
3262 // TODO(ahe): Move this code to a JavaScript command helper script that is 3261 // TODO(ahe): Move this code to a JavaScript command helper script that is
3263 // not included in generated output. 3262 // not included in generated output.
3264 return _loadingLibraries[hunkName] = new Future<Null>(() { 3263 return _loadingLibraries[hunkName] = new Future<Null>(() {
3265 try { 3264 try {
3266 // Create a new function to avoid getting access to current function 3265 // Create a new function to avoid getting access to current function
3267 // context. 3266 // context.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 throw new MainError("No top-level function named 'main'."); 3347 throw new MainError("No top-level function named 'main'.");
3349 } 3348 }
3350 3349
3351 void badMain() { 3350 void badMain() {
3352 throw new MainError("'main' is not a function."); 3351 throw new MainError("'main' is not a function.");
3353 } 3352 }
3354 3353
3355 void mainHasTooManyParameters() { 3354 void mainHasTooManyParameters() {
3356 throw new MainError("'main' expects too many parameters."); 3355 throw new MainError("'main' expects too many parameters.");
3357 } 3356 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/async_patch.dart ('k') | sdk/lib/async/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698