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

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

Issue 155213002: Add a bunch of toString methods to internal Barback classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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_id.dart'; 10 import 'asset_id.dart';
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return onStateChange.firstWhere(test).then((_) => callback(state)); 130 return onStateChange.firstWhere(test).then((_) => callback(state));
131 } 131 }
132 132
133 AssetNode._(this.id, this._transform, this._origin) 133 AssetNode._(this.id, this._transform, this._origin)
134 : _state = AssetState.DIRTY; 134 : _state = AssetState.DIRTY;
135 135
136 AssetNode._available(Asset asset, this._transform, this._origin) 136 AssetNode._available(Asset asset, this._transform, this._origin)
137 : id = asset.id, 137 : id = asset.id,
138 _asset = asset, 138 _asset = asset,
139 _state = AssetState.AVAILABLE; 139 _state = AssetState.AVAILABLE;
140
141 String toString() => "$state asset $id";
140 } 142 }
141 143
142 /// The controller for an [AssetNode]. 144 /// The controller for an [AssetNode].
143 /// 145 ///
144 /// This controls which state the node is in. 146 /// This controls which state the node is in.
145 class AssetNodeController { 147 class AssetNodeController {
146 final AssetNode node; 148 final AssetNode node;
147 149
148 /// Creates a controller for a dirty node. 150 /// Creates a controller for a dirty node.
149 AssetNodeController(AssetId id, [TransformNode transform]) 151 AssetNodeController(AssetId id, [TransformNode transform])
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 /// It's an error to mark an already-available node as available. It should be 194 /// It's an error to mark an already-available node as available. It should be
193 /// marked as dirty first. 195 /// marked as dirty first.
194 void setAvailable(Asset asset) { 196 void setAvailable(Asset asset) {
195 assert(asset.id == node.id); 197 assert(asset.id == node.id);
196 assert(node._state != AssetState.REMOVED); 198 assert(node._state != AssetState.REMOVED);
197 assert(node._state != AssetState.AVAILABLE); 199 assert(node._state != AssetState.AVAILABLE);
198 node._state = AssetState.AVAILABLE; 200 node._state = AssetState.AVAILABLE;
199 node._asset = asset; 201 node._asset = asset;
200 node._stateChangeController.add(AssetState.AVAILABLE); 202 node._stateChangeController.add(AssetState.AVAILABLE);
201 } 203 }
204
205 String toString() => "controller for $node";
202 } 206 }
203 207
204 // TODO(nweiz): add an error state. 208 // TODO(nweiz): add an error state.
205 /// An enum of states that an [AssetNode] can be in. 209 /// An enum of states that an [AssetNode] can be in.
206 class AssetState { 210 class AssetState {
207 /// The node has a concrete asset loaded, available, and up-to-date. The asset 211 /// The node has a concrete asset loaded, available, and up-to-date. The asset
208 /// is accessible via [AssetNode.asset]. An asset can only be marked available 212 /// is accessible via [AssetNode.asset]. An asset can only be marked available
209 /// again from the [AssetState.DIRTY] state. 213 /// again from the [AssetState.DIRTY] state.
210 static final AVAILABLE = const AssetState._("available"); 214 static final AVAILABLE = const AssetState._("available");
211 215
(...skipping 13 matching lines...) Expand all
225 229
226 /// Whether this state is [AssetState.DIRTY]. 230 /// Whether this state is [AssetState.DIRTY].
227 bool get isDirty => this == AssetState.DIRTY; 231 bool get isDirty => this == AssetState.DIRTY;
228 232
229 final String name; 233 final String name;
230 234
231 const AssetState._(this.name); 235 const AssetState._(this.name);
232 236
233 String toString() => name; 237 String toString() => name;
234 } 238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698