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

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

Issue 255283003: Don't assume that a transform node is consistently deferred or not. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 Asset _asset; 51 Asset _asset;
52 52
53 /// The callback to be called to notify this asset node's creator that the 53 /// The callback to be called to notify this asset node's creator that the
54 /// concrete asset should be generated. 54 /// concrete asset should be generated.
55 /// 55 ///
56 /// This is null for non-lazy asset nodes (see [AssetNodeController.lazy]). 56 /// This is null for non-lazy asset nodes (see [AssetNodeController.lazy]).
57 /// Once this is called, it's set to null and [this] is no longer considered 57 /// Once this is called, it's set to null and [this] is no longer considered
58 /// lazy. 58 /// lazy.
59 Function _lazyCallback; 59 Function _lazyCallback;
60 60
61 /// Whether this asset's transform is deferred. 61 /// Whether this node is lazy, meaning that [force] must be called to
62 /// 62 /// guarantee that it will eventually become available.
63 /// See [TransformNode.deferred]. 63 bool get isLazy => _lazyCallback != null ||
64 bool get deferred => transform != null && transform.deferred; 64 (_origin != null && _origin.isLazy);
65 65
66 /// A broadcast stream that emits an event whenever the node changes state. 66 /// A broadcast stream that emits an event whenever the node changes state.
67 /// 67 ///
68 /// This stream is synchronous to ensure that when a source asset is modified 68 /// This stream is synchronous to ensure that when a source asset is modified
69 /// or removed, the appropriate portion of the asset graph is dirtied before 69 /// or removed, the appropriate portion of the asset graph is dirtied before
70 /// any [Barback.getAssetById] calls emit newly-incorrect values. 70 /// any [Barback.getAssetById] calls emit newly-incorrect values.
71 Stream<AssetState> get onStateChange => _stateChangeController.stream; 71 Stream<AssetState> get onStateChange => _stateChangeController.stream;
72 72
73 /// This is synchronous so that a source being updated will always be 73 /// This is synchronous so that a source being updated will always be
74 /// propagated through the build graph before anything that depends on it is 74 /// propagated through the build graph before anything that depends on it is
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 /// See [AssetNodeController.lazy]. 138 /// See [AssetNodeController.lazy].
139 void force() { 139 void force() {
140 if (_origin != null) { 140 if (_origin != null) {
141 _origin.force(); 141 _origin.force();
142 } else if (_lazyCallback != null) { 142 } else if (_lazyCallback != null) {
143 _lazyCallback(); 143 _lazyCallback();
144 _lazyCallback = null; 144 _lazyCallback = null;
145 } 145 }
146 } 146 }
147 147
148 String toString() => 148 String toString() => "${isLazy ? 'lazy' : state} asset $id";
149 "$state${_lazyCallback == null ? '' : ' lazy'} asset $id";
150 } 149 }
151 150
152 /// The controller for an [AssetNode]. 151 /// The controller for an [AssetNode].
153 /// 152 ///
154 /// This controls which state the node is in. 153 /// This controls which state the node is in.
155 class AssetNodeController { 154 class AssetNodeController {
156 final AssetNode node; 155 final AssetNode node;
157 156
158 /// Creates a controller for a dirty node. 157 /// Creates a controller for a dirty node.
159 AssetNodeController(AssetId id, [TransformNode transform]) 158 AssetNodeController(AssetId id, [TransformNode transform])
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 274
276 /// Whether this state is [AssetState.RUNNING]. 275 /// Whether this state is [AssetState.RUNNING].
277 bool get isDirty => this == AssetState.RUNNING; 276 bool get isDirty => this == AssetState.RUNNING;
278 277
279 final String name; 278 final String name;
280 279
281 const AssetState._(this.name); 280 const AssetState._(this.name);
282 281
283 String toString() => name; 282 String toString() => name;
284 } 283 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/lib/src/phase_input.dart » ('j') | pkg/barback/test/package_graph/declaring_transformer_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698