| 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.phase_forwarder; | 5 library barback.phase_forwarder; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset_node.dart'; | 9 import 'asset_node.dart'; |
| 10 import 'asset_forwarder.dart'; | 10 import 'asset_forwarder.dart'; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (_intermediateAssets.length < _numChannels) { | 103 if (_intermediateAssets.length < _numChannels) { |
| 104 if (_outputController == null) return; | 104 if (_outputController == null) return; |
| 105 _outputController.setRemoved(); | 105 _outputController.setRemoved(); |
| 106 _outputController = null; | 106 _outputController = null; |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // If there isn't a final asset being forwarded yet, we should forward one. | 110 // If there isn't a final asset being forwarded yet, we should forward one. |
| 111 // It should be dirty iff any of the intermediate assets are dirty. | 111 // It should be dirty iff any of the intermediate assets are dirty. |
| 112 if (_outputController == null) { | 112 if (_outputController == null) { |
| 113 var asset = _intermediateAssets.firstWhere((asset) => asset.state.isDirty, | 113 var finalAsset = _intermediateAssets.firstWhere( |
| 114 (asset) => asset.state.isDirty, |
| 114 orElse: () => _intermediateAssets.first); | 115 orElse: () => _intermediateAssets.first); |
| 115 _outputController = new AssetNodeController.from(asset); | 116 _outputController = new AssetNodeController.from(finalAsset); |
| 116 _onForwardingController.add(output); | 117 _onForwardingController.add(output); |
| 117 return; | 118 return; |
| 118 } | 119 } |
| 119 | 120 |
| 120 // If we're already forwarding a final asset, set it dirty iff any of the | 121 // If we're already forwarding a final asset, set it dirty iff any of the |
| 121 // intermediate assets are dirty. | 122 // intermediate assets are dirty. |
| 122 if (_intermediateAssets.any((asset) => asset.state.isDirty)) { | 123 if (_intermediateAssets.any((asset) => asset.state.isDirty)) { |
| 123 if (!_outputController.node.state.isDirty) _outputController.setDirty(); | 124 if (!_outputController.node.state.isDirty) _outputController.setDirty(); |
| 124 } else { | 125 } else { |
| 125 if (!_outputController.node.state.isAvailable) { | 126 if (!_outputController.node.state.isAvailable) { |
| 126 _outputController.setAvailable(_intermediateAssets.first.asset); | 127 _outputController.setAvailable(_intermediateAssets.first.asset); |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 } | 130 } |
| 130 } | 131 } |
| OLD | NEW |