| OLD | NEW |
| 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 barback.graph.asset_cascade; | 5 library barback.graph.asset_cascade; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../asset/asset.dart'; | 9 import '../asset/asset.dart'; |
| 10 import '../asset/asset_id.dart'; | 10 import '../asset/asset_id.dart'; |
| 11 import '../asset/asset_node.dart'; | 11 import '../asset/asset_node.dart'; |
| 12 import '../asset/asset_set.dart'; | 12 import '../asset/asset_set.dart'; |
| 13 import '../errors.dart'; | 13 import '../errors.dart'; |
| 14 import '../log.dart'; | 14 import '../log.dart'; |
| 15 import '../transformer/transformer.dart'; | 15 import '../transformer/transformer.dart'; |
| 16 import '../utils.dart'; |
| 16 import '../utils/cancelable_future.dart'; | 17 import '../utils/cancelable_future.dart'; |
| 17 import 'node_status.dart'; | 18 import 'node_status.dart'; |
| 18 import 'node_streams.dart'; | 19 import 'node_streams.dart'; |
| 19 import 'package_graph.dart'; | 20 import 'package_graph.dart'; |
| 20 import 'phase.dart'; | 21 import 'phase.dart'; |
| 21 | 22 |
| 22 /// The asset cascade for an individual package. | 23 /// The asset cascade for an individual package. |
| 23 /// | 24 /// |
| 24 /// This keeps track of which [Transformer]s are applied to which assets, and | 25 /// This keeps track of which [Transformer]s are applied to which assets, and |
| 25 /// re-runs those transformers when their dependencies change. The transformed | 26 /// re-runs those transformers when their dependencies change. The transformed |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 controller.setDirty(); | 132 controller.setDirty(); |
| 132 } else { | 133 } else { |
| 133 _sourceControllerMap[id] = new AssetNodeController(id); | 134 _sourceControllerMap[id] = new AssetNodeController(id); |
| 134 _phases.first.addInput(_sourceControllerMap[id].node); | 135 _phases.first.addInput(_sourceControllerMap[id].node); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // If this source was already loading, cancel the old load, since it may | 138 // If this source was already loading, cancel the old load, since it may |
| 138 // return out-of-date contents for the asset. | 139 // return out-of-date contents for the asset. |
| 139 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel(); | 140 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel(); |
| 140 | 141 |
| 141 _loadingSources[id] = | 142 _loadingSources[id] = new CancelableFuture<Asset>( |
| 142 new CancelableFuture<Asset>(graph.provider.getAsset(id)); | 143 syncFuture(() => graph.provider.getAsset(id))); |
| 143 _loadingSources[id].whenComplete(() { | 144 _loadingSources[id].whenComplete(() { |
| 144 _loadingSources.remove(id); | 145 _loadingSources.remove(id); |
| 145 }).then((asset) { | 146 }).then((asset) { |
| 146 var controller = _sourceControllerMap[id].setAvailable(asset); | 147 var controller = _sourceControllerMap[id].setAvailable(asset); |
| 147 }).catchError((error, stack) { | 148 }).catchError((error, stack) { |
| 148 reportError(new AssetLoadException(id, error, stack)); | 149 reportError(new AssetLoadException(id, error, stack)); |
| 149 | 150 |
| 150 // TODO(nweiz): propagate error information through asset nodes. | 151 // TODO(nweiz): propagate error information through asset nodes. |
| 151 _sourceControllerMap.remove(id).setRemoved(); | 152 _sourceControllerMap.remove(id).setRemoved(); |
| 152 }); | 153 }); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 _streams.onLogPool.add(phase.onLog); | 214 _streams.onLogPool.add(phase.onLog); |
| 214 if (_phaseStatusSubscription != null) _phaseStatusSubscription.cancel(); | 215 if (_phaseStatusSubscription != null) _phaseStatusSubscription.cancel(); |
| 215 _phaseStatusSubscription = | 216 _phaseStatusSubscription = |
| 216 phase.onStatusChange.listen(_streams.changeStatus); | 217 phase.onStatusChange.listen(_streams.changeStatus); |
| 217 | 218 |
| 218 _phases.add(phase); | 219 _phases.add(phase); |
| 219 } | 220 } |
| 220 | 221 |
| 221 String toString() => "cascade for $package"; | 222 String toString() => "cascade for $package"; |
| 222 } | 223 } |
| OLD | NEW |