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

Side by Side 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 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.asset_node; 5 library barback.asset_node;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'asset.dart'; 9 import 'asset.dart';
10 import 'asset_graph.dart'; 10 import 'asset_graph.dart';
11 import 'asset_id.dart'; 11 import 'asset_id.dart';
12 import 'phase.dart'; 12 import 'phase.dart';
13 import 'transform_node.dart'; 13 import 'transform_node.dart';
14 14
15 /// Describes an asset and its relationship to the build dependency graph. 15 /// Describes an asset and its relationship to the build dependency graph.
16 /// 16 ///
17 /// Keeps a cache of the last asset that was built for this node (i.e. for this 17 /// Keeps a cache of the last asset that was built for this node (i.e. for this
18 /// node's ID and phase) and tracks which transforms depend on it. 18 /// node's ID and phase) and tracks which transforms depend on it.
19 class AssetNode { 19 class AssetNode {
20 final AssetId id;
21 Asset asset; 20 Asset asset;
22 21
23 /// The [TransformNode]s that consume this node's asset as an input. 22 /// The [TransformNode]s that consume this node's asset as an input.
24 final consumers = new Set<TransformNode>(); 23 final consumers = new Set<TransformNode>();
25 24
26 AssetNode(this.id); 25 AssetId get id => asset.id;
26
27 AssetNode(this.asset);
27 28
28 /// Updates this node's generated asset value and marks all transforms that 29 /// Updates this node's generated asset value and marks all transforms that
29 /// use this as dirty. 30 /// use this as dirty.
30 void updateAsset(Asset asset) { 31 void updateAsset(Asset asset) {
32 // Cannot update an asset to one with a different ID.
33 assert(id == asset.id);
34
31 this.asset = asset; 35 this.asset = asset;
32 consumers.forEach((consumer) => consumer.dirty()); 36 consumers.forEach((consumer) => consumer.dirty());
33 } 37 }
34 } 38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698