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

Side by Side Diff: pkg/barback/lib/src/phase.dart

Issue 196273003: Move isPrimary computation from PhaseInput into TransformNode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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 | « no previous file | pkg/barback/lib/src/phase_forwarder.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 barback.phase; 5 library barback.phase;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'asset_cascade.dart'; 9 import 'asset_cascade.dart';
10 import 'asset_id.dart'; 10 import 'asset_id.dart';
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 /// is called, however. 166 /// is called, however.
167 /// 167 ///
168 /// This should only be used for brand-new assets or assets that have been 168 /// This should only be used for brand-new assets or assets that have been
169 /// removed and re-created. The phase will automatically handle updated assets 169 /// removed and re-created. The phase will automatically handle updated assets
170 /// using the [AssetNode.onStateChange] stream. 170 /// using the [AssetNode.onStateChange] stream.
171 void addInput(AssetNode node) { 171 void addInput(AssetNode node) {
172 if (_inputs.containsKey(node.id)) _inputs[node.id].remove(); 172 if (_inputs.containsKey(node.id)) _inputs[node.id].remove();
173 173
174 node.force(); 174 node.force();
175 175
176 // Each group is one channel along which an asset may be forwarded. Then 176 // Each group is one channel along which an asset may be forwarded, as is
177 // there's one additional channel for the non-grouped transformers. 177 // each transformer.
178 var forwarder = new PhaseForwarder(_groups.length + 1); 178 var forwarder = new PhaseForwarder(
179 node, _transformers.length, _groups.length);
179 _forwarders[node.id] = forwarder; 180 _forwarders[node.id] = forwarder;
180 forwarder.onAsset.listen(_handleOutputWithoutForwarder); 181 forwarder.onAsset.listen(_handleOutputWithoutForwarder);
182 if (forwarder.output != null) {
183 _handleOutputWithoutForwarder(forwarder.output);
184 }
181 185
182 _inputOrigins.add(node.origin); 186 _inputOrigins.add(node.origin);
183 var input = new PhaseInput(this, node, _transformers, "$_location.$_index"); 187 var input = new PhaseInput(this, node, "$_location.$_index");
184 _inputs[node.id] = input; 188 _inputs[node.id] = input;
185 input.input.whenRemoved(() { 189 input.input.whenRemoved(() {
186 _inputOrigins.remove(node.origin); 190 _inputOrigins.remove(node.origin);
187 _inputs.remove(node.id); 191 _inputs.remove(node.id);
188 _forwarders.remove(node.id).remove(); 192 _forwarders.remove(node.id).remove();
189 if (!isDirty) _onDoneController.add(null); 193 if (!isDirty) _onDoneController.add(null);
190 }); 194 });
191 input.onAsset.listen(_handleOutput); 195 input.onAsset.listen(_handleOutput);
192 _onLogPool.add(input.onLog); 196 _onLogPool.add(input.onLog);
193 input.onDone.listen((_) { 197 input.onDone.listen((_) {
194 if (!isDirty) _onDoneController.add(null); 198 if (!isDirty) _onDoneController.add(null);
195 }); 199 });
196 200
201 input.updateTransformers(_transformers);
202
197 for (var group in _groups.values) { 203 for (var group in _groups.values) {
198 group.addInput(node); 204 group.addInput(node);
199 } 205 }
200 } 206 }
201 207
202 // TODO(nweiz): If the input is available when this is called, it's 208 // TODO(nweiz): If the input is available when this is called, it's
203 // theoretically possible for it to become unavailable between the call and 209 // theoretically possible for it to become unavailable between the call and
204 // the return. If it does so, it won't trigger the rebuilding process. To 210 // the return. If it does so, it won't trigger the rebuilding process. To
205 // avoid this, we should have this and the methods it calls take explicit 211 // avoid this, we should have this and the methods it calls take explicit
206 // callbacks, as in [AssetNode.whenAvailable]. 212 // callbacks, as in [AssetNode.whenAvailable].
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (id.package != cascade.package) return cascade.graph.getAssetNode(id); 244 if (id.package != cascade.package) return cascade.graph.getAssetNode(id);
239 if (_outputs.containsKey(id)) { 245 if (_outputs.containsKey(id)) {
240 var output = _outputs[id].output; 246 var output = _outputs[id].output;
241 // If the requested output is available, we can just return it. 247 // If the requested output is available, we can just return it.
242 if (output.state.isAvailable) return output; 248 if (output.state.isAvailable) return output;
243 249
244 // If the requested output exists but isn't yet available, wait to see 250 // If the requested output exists but isn't yet available, wait to see
245 // if it becomes available. If it's removed before becoming available, 251 // if it becomes available. If it's removed before becoming available,
246 // try again, since it could be generated again. 252 // try again, since it could be generated again.
247 output.force(); 253 output.force();
248 return output.whenAvailable((_) => output).catchError((error) { 254 return output.whenAvailable((_) {
255 return output;
256 }).catchError((error) {
249 if (error is! AssetNotFoundException) throw error; 257 if (error is! AssetNotFoundException) throw error;
250 return getOutput(id); 258 return getOutput(id);
251 }); 259 });
252 } 260 }
253 261
254 // If neither this phase nor the previous phases are dirty, the requested 262 // If neither this phase nor the previous phases are dirty, the requested
255 // output won't be generated and we can safely return null. 263 // output won't be generated and we can safely return null.
256 if (!isDirty) return null; 264 if (!isDirty) return null;
257 265
258 // Otherwise, store a completer for the asset node. If it's generated in 266 // Otherwise, store a completer for the asset node. If it's generated in
(...skipping 27 matching lines...) Expand all
286 _onLogPool.add(runner.onLog); 294 _onLogPool.add(runner.onLog);
287 runner.onDone.listen((_) { 295 runner.onDone.listen((_) {
288 if (!isDirty) _onDoneController.add(null); 296 if (!isDirty) _onDoneController.add(null);
289 }); 297 });
290 for (var input in _inputs.values) { 298 for (var input in _inputs.values) {
291 runner.addInput(input.input); 299 runner.addInput(input.input);
292 } 300 }
293 } 301 }
294 302
295 for (var forwarder in _forwarders.values) { 303 for (var forwarder in _forwarders.values) {
296 forwarder.numChannels = _groups.length + 1; 304 forwarder.updateTransformers(_transformers.length, _groups.length);
297 } 305 }
298 } 306 }
299 307
300 /// Force all [LazyTransformer]s' transforms in this phase to begin producing 308 /// Force all [LazyTransformer]s' transforms in this phase to begin producing
301 /// concrete assets. 309 /// concrete assets.
302 void forceAllTransforms() { 310 void forceAllTransforms() {
303 for (var group in _groups.values) { 311 for (var group in _groups.values) {
304 group.forceAllTransforms(); 312 group.forceAllTransforms();
305 } 313 }
306 314
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 assert(asset.state.isDirty); 412 assert(asset.state.isDirty);
405 asset.force(); 413 asset.force();
406 asset.whenStateChanges().then((state) { 414 asset.whenStateChanges().then((state) {
407 if (state.isRemoved) return getOutput(asset.id); 415 if (state.isRemoved) return getOutput(asset.id);
408 return asset; 416 return asset;
409 }).then(request.complete).catchError(request.completeError); 417 }).then(request.complete).catchError(request.completeError);
410 } 418 }
411 419
412 String toString() => "phase $_location.$_index"; 420 String toString() => "phase $_location.$_index";
413 } 421 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/lib/src/phase_forwarder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698