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

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

Issue 189263002: Make Phase.getInput in barback play nicely with the push model. (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
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.transform_node; 5 library barback.transform_node;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:source_maps/span.dart'; 9 import 'package:source_maps/span.dart';
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 /// 222 ///
223 /// If an input with that ID cannot be found, throws an 223 /// If an input with that ID cannot be found, throws an
224 /// [AssetNotFoundException]. 224 /// [AssetNotFoundException].
225 Future<Asset> getInput(AssetId id) { 225 Future<Asset> getInput(AssetId id) {
226 return phase.getInput(id).then((node) { 226 return phase.getInput(id).then((node) {
227 // Throw if the input isn't found. This ensures the transformer's apply 227 // Throw if the input isn't found. This ensures the transformer's apply
228 // is exited. We'll then catch this and report it through the proper 228 // is exited. We'll then catch this and report it through the proper
229 // results stream. 229 // results stream.
230 if (node == null) throw new MissingInputException(info, id); 230 if (node == null) throw new MissingInputException(info, id);
231 231
232 // If the asset node is found, wait until its contents are actually 232 _inputSubscriptions.putIfAbsent(node.id,
233 // available before we return them. 233 () => node.onStateChange.listen((_) => _dirty()));
234 return node.whenAvailable((asset) {
235 _inputSubscriptions.putIfAbsent(node.id,
236 () => node.onStateChange.listen((_) => _dirty()));
237 234
238 return asset; 235 return node.asset;
239 }).catchError((error) {
240 if (error is! AssetNotFoundException || error.id != id) throw error;
241 // If the node was removed before it could be loaded, treat it as though
242 // it never existed and throw a MissingInputException.
243 throw new MissingInputException(info, id);
244 });
245 }); 236 });
246 } 237 }
247 238
248 /// Applies the transform so that it produces concrete (as opposed to lazy) 239 /// Applies the transform so that it produces concrete (as opposed to lazy)
249 /// outputs. 240 /// outputs.
250 Future _applyImmediate() { 241 Future _applyImmediate() {
251 var newOutputs = new AssetSet(); 242 var newOutputs = new AssetSet();
252 var transform = new Transform(this, newOutputs, _log); 243 var transform = new Transform(this, newOutputs, _log);
253 244
254 return syncFuture(() => transformer.apply(transform)).then((_) { 245 return syncFuture(() => transformer.apply(transform)).then((_) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 void _log(AssetId asset, LogLevel level, String message, Span span) { 317 void _log(AssetId asset, LogLevel level, String message, Span span) {
327 // If the log isn't already associated with an asset, use the primary. 318 // If the log isn't already associated with an asset, use the primary.
328 if (asset == null) asset = primary.id; 319 if (asset == null) asset = primary.id;
329 var entry = new LogEntry(info, asset, level, message, span); 320 var entry = new LogEntry(info, asset, level, message, span);
330 _onLogController.add(entry); 321 _onLogController.add(entry);
331 } 322 }
332 323
333 String toString() => 324 String toString() =>
334 "transform node in $_location for $transformer on $primary"; 325 "transform node in $_location for $transformer on $primary";
335 } 326 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | pkg/barback/test/package_graph/transform/concurrency_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698