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

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

Issue 18650004: Make Assets know their ID. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't make AssetSet implement Set<T>. Created 7 years, 5 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
Index: pkg/barback/lib/src/asset_node.dart
diff --git a/pkg/barback/lib/src/asset_node.dart b/pkg/barback/lib/src/asset_node.dart
index 6fd86c622d7fab8058c23f134104e2f02690c719..7bef7a0afa1ad238b3607abbf28dd1f01fbf2252 100644
--- a/pkg/barback/lib/src/asset_node.dart
+++ b/pkg/barback/lib/src/asset_node.dart
@@ -17,17 +17,21 @@ import 'transform_node.dart';
/// Keeps a cache of the last asset that was built for this node (i.e. for this
/// node's ID and phase) and tracks which transforms depend on it.
class AssetNode {
- final AssetId id;
Asset asset;
/// The [TransformNode]s that consume this node's asset as an input.
final consumers = new Set<TransformNode>();
- AssetNode(this.id);
+ AssetId get id => asset.id;
+
+ AssetNode(this.asset);
/// Updates this node's generated asset value and marks all transforms that
/// use this as dirty.
void updateAsset(Asset asset) {
+ // Cannot update an asset to one with a different ID.
+ assert(id == asset.id);
+
this.asset = asset;
consumers.forEach((consumer) => consumer.dirty());
}

Powered by Google App Engine
This is Rietveld 408576698