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

Unified Diff: pkg/barback/lib/src/asset_cascade.dart

Issue 23199004: Support passing barback assets through phases in which they're unused. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a logic error. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/barback/lib/src/barback.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset_cascade.dart
diff --git a/pkg/barback/lib/src/asset_cascade.dart b/pkg/barback/lib/src/asset_cascade.dart
index af48a47cb5e10809280a985f21cb3b99ddac1602..341480d94ac92ff55ac8425d54331e7bc682a9b1 100644
--- a/pkg/barback/lib/src/asset_cascade.dart
+++ b/pkg/barback/lib/src/asset_cascade.dart
@@ -113,8 +113,10 @@ class AssetCascade {
/// Gets the asset identified by [id].
///
/// If [id] is for a generated or transformed asset, this will wait until it
- /// has been created and return it. If the asset cannot be found, returns
- /// null.
+ /// has been created and return it. This means that the returned asset will
+ /// always be [AssetState.AVAILABLE].
+ ///
+ /// If the asset cannot be found, returns null.
Future<AssetNode> getAssetNode(AssetId id) {
assert(id.package == package);
@@ -126,11 +128,9 @@ class AssetCascade {
// * If [id] has never been generated and all active transformers provide
// metadata about the file names of assets it can emit, we can prove that
// none of them can emit [id] and fail early.
- return newFuture(() {
- var node = _getAssetNode(id);
-
+ return _phases.last.getInput(id).then((node) {
// If the requested asset is available, we can just return it.
- if (node != null) return node;
+ if (node != null && node.state.isAvailable) return node;
// If there's a build running, that build might generate the asset, so we
// wait for it to complete and then try again.
@@ -144,24 +144,6 @@ class AssetCascade {
});
}
- // Returns the post-transformation asset node for [id], if one is available.
- //
- // This will only return a node that has an asset available, and only if that
- // node is guaranteed not to be consumed by any transforms. If the phase is
- // still working to figure out if a node will be consumed by a transformer,
- // that node won't be returned.
- AssetNode _getAssetNode(AssetId id) {
- // Each phase's inputs are the outputs of the previous phase. Find the last
- // phase that contains the asset. Since the last phase has no transformers,
- // this will find the latest output for that id.
- for (var i = _phases.length - 1; i >= 0; i--) {
- var node = _phases[i].getUnconsumedInput(id);
- if (node != null) return node;
- }
-
- return null;
- }
-
/// Adds [sources] to the graph's known set of source assets.
///
/// Begins applying any transforms that can consume any of the sources. If a
« no previous file with comments | « no previous file | pkg/barback/lib/src/barback.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698