| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import "dart:async"; | 5 import "dart:async"; |
| 6 import "dart:isolate"; | 6 import "dart:isolate"; |
| 7 | 7 |
| 8 // This type corresponds to the VM-internal class LibraryPrefix. | 8 // This type corresponds to the VM-internal class LibraryPrefix. |
| 9 class _LibraryPrefix { | 9 class _LibraryPrefix { |
| 10 | 10 |
| 11 bool _load() native "LibraryPrefix_load"; | 11 bool _load() native "LibraryPrefix_load"; |
| 12 Error _loadError() native "LibraryPrefix_loadError"; |
| 12 | 13 |
| 13 bool _invalidateDependentCode() | 14 bool _invalidateDependentCode() |
| 14 native "LibraryPrefix_invalidateDependentCode"; | 15 native "LibraryPrefix_invalidateDependentCode"; |
| 15 | 16 |
| 16 loadLibrary() { | 17 loadLibrary() { |
| 17 var completer = _outstandingLoadRequests[this]; | 18 var completer = _outstandingLoadRequests[this]; |
| 18 if (completer != null) { | 19 if (completer != null) { |
| 19 return completer.future; | 20 return completer.future; |
| 20 } | 21 } |
| 21 completer = new Completer<bool>(); | 22 completer = new Completer<bool>(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 return completer.future; | 37 return completer.future; |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 var _outstandingLoadRequests = new Map<_LibraryPrefix, Completer>(); | 41 var _outstandingLoadRequests = new Map<_LibraryPrefix, Completer>(); |
| 41 | 42 |
| 42 | 43 |
| 43 // Called from the VM when all outstanding load requests have | 44 // Called from the VM when all outstanding load requests have |
| 44 // finished. | 45 // finished. |
| 45 _completeDeferredLoads() { | 46 _completeDeferredLoads() { |
| 46 var lenghth = _outstandingLoadRequests; | |
| 47 _outstandingLoadRequests.forEach((prefix, completer) { | 47 _outstandingLoadRequests.forEach((prefix, completer) { |
| 48 prefix._invalidateDependentCode(); | 48 var error = prefix._loadError(); |
| 49 completer.complete(true); | 49 if (error != null) { |
| 50 completer.completeError(error); |
| 51 } else { |
| 52 prefix._invalidateDependentCode(); |
| 53 completer.complete(true); |
| 54 } |
| 50 }); | 55 }); |
| 51 _outstandingLoadRequests.clear(); | 56 _outstandingLoadRequests.clear(); |
| 52 } | 57 } |
| OLD | NEW |