Index: runtime/lib/lib_prefix.dart |
diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart |
index 4f509da5bff4a23e95cbea1eed136bfcd5357576..9d5af287e9e25e79f56e8ca99c2cb7e8318687c3 100644 |
--- a/runtime/lib/lib_prefix.dart |
+++ b/runtime/lib/lib_prefix.dart |
@@ -46,19 +46,27 @@ class _LibraryPrefix { |
// second element is the Completer for the load request. |
var _outstandingLoadRequests = new List<List>(); |
-// Called from the VM when all outstanding load requests have |
-// finished. |
+// Called from the VM when an outstanding load request has finished. |
_completeDeferredLoads() { |
+ // Determine which outstanding load requests have completed and complete |
+ // their completer (with an error or true). For outstanding load requests |
+ // which have not completed, remember them for next time in |
+ // stillOutstandingLoadRequests. |
+ var stillOutstandingLoadRequests = new List<List>(); |
for (int i = 0; i < _outstandingLoadRequests.length; i++) { |
var prefix = _outstandingLoadRequests[i][0]; |
- var completer = _outstandingLoadRequests[i][1]; |
- var error = prefix._loadError(); |
- if (error != null) { |
- completer.completeError(error); |
+ if (prefix._load()) { |
+ var completer = _outstandingLoadRequests[i][1]; |
+ var error = prefix._loadError(); |
+ if (error != null) { |
+ completer.completeError(error); |
+ } else { |
+ prefix._invalidateDependentCode(); |
+ completer.complete(true); |
+ } |
} else { |
- prefix._invalidateDependentCode(); |
- completer.complete(true); |
+ stillOutstandingLoadRequests.add(_outstandingLoadRequests[i]); |
} |
} |
- _outstandingLoadRequests.clear(); |
+ _outstandingLoadRequests = stillOutstandingLoadRequests; |
} |