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

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

Issue 18650004: Make Assets know their ID. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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_graph; 5 library barback.asset_graph;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'asset.dart'; 10 import 'asset.dart';
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // changes are processed in a single batch even when the first one starts 183 // changes are processed in a single batch even when the first one starts
184 // the build process. 184 // the build process.
185 return new Future(() { 185 return new Future(() {
186 if (_sourceChanges == null) return null; 186 if (_sourceChanges == null) return null;
187 187
188 // Take the current batch to ensure it doesn't get added to while we're 188 // Take the current batch to ensure it doesn't get added to while we're
189 // processing it. 189 // processing it.
190 var changes = _sourceChanges; 190 var changes = _sourceChanges;
191 _sourceChanges = null; 191 _sourceChanges = null;
192 192
193 var updated = new Map<AssetId, Asset>(); 193 var updated = new Set<Asset>();
nweiz 2013/07/03 20:08:25 Does Set<Asset> work? Asset doesn't define [hash]
Bob Nystrom 2013/07/03 22:32:11 Object implements hashCode and == (based on identi
194 var futures = []; 194 var futures = [];
195 for (var id in changes.updated) { 195 for (var id in changes.updated) {
196 // TODO(rnystrom): Catch all errors from provider and route to results. 196 // TODO(rnystrom): Catch all errors from provider and route to results.
197 futures.add(_provider.getAsset(id).then((asset) { 197 futures.add(_provider.getAsset(id).then((asset) {
198 updated[id] = asset; 198 updated.add(asset);
199 }).catchError((error) { 199 }).catchError((error) {
200 if (error is AssetNotFoundException) { 200 if (error is AssetNotFoundException) {
201 // Handle missing asset errors like regular missing assets. 201 // Handle missing asset errors like regular missing assets.
202 reportError(error); 202 reportError(error);
203 } else { 203 } else {
204 // It's an unexpected error, so rethrow it. 204 // It's an unexpected error, so rethrow it.
205 throw error; 205 throw error;
206 } 206 }
207 })); 207 }));
208 } 208 }
209 209
210 return Future.wait(futures).then((_) { 210 return Future.wait(futures).then((_) {
211 _phases.first.updateInputs(updated, changes.removed); 211 _phases.first.updateInputs(updated, changes.removed);
212 }); 212 });
213 }); 213 });
214 } 214 }
215 } 215 }
216 216
217 /// Used to report build results back from the asynchronous build process 217 /// Used to report build results back from the asynchronous build process
218 /// running in the background. 218 /// running in the background.
219 class BuildResult { 219 class BuildResult {
220 /// The error that occurred, or `null` if the result is not an error. 220 /// The error that occurred, or `null` if the result is not an error.
221 final error; 221 final error;
222 222
223 /// `true` if this result is for a successful build. 223 /// `true` if this result is for a successful build.
224 bool get succeeded => error == null; 224 bool get succeeded => error == null;
225 225
226 BuildResult([this.error]); 226 BuildResult([this.error]);
227 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698