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

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: Add AssetSet and revise. 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';
11 import 'asset_id.dart'; 11 import 'asset_id.dart';
12 import 'asset_provider.dart'; 12 import 'asset_provider.dart';
13 import 'asset_set.dart';
13 import 'errors.dart'; 14 import 'errors.dart';
14 import 'change_batch.dart'; 15 import 'change_batch.dart';
15 import 'phase.dart'; 16 import 'phase.dart';
16 import 'transformer.dart'; 17 import 'transformer.dart';
17 18
18 /// The main build dependency manager. 19 /// The main build dependency manager.
19 /// 20 ///
20 /// For any given input file, it can tell which output files are affected by 21 /// For any given input file, it can tell which output files are affected by
21 /// it, and vice versa. 22 /// it, and vice versa.
22 class AssetGraph { 23 class AssetGraph {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // changes are processed in a single batch even when the first one starts 184 // changes are processed in a single batch even when the first one starts
184 // the build process. 185 // the build process.
185 return new Future(() { 186 return new Future(() {
186 if (_sourceChanges == null) return null; 187 if (_sourceChanges == null) return null;
187 188
188 // Take the current batch to ensure it doesn't get added to while we're 189 // Take the current batch to ensure it doesn't get added to while we're
189 // processing it. 190 // processing it.
190 var changes = _sourceChanges; 191 var changes = _sourceChanges;
191 _sourceChanges = null; 192 _sourceChanges = null;
192 193
193 var updated = new Map<AssetId, Asset>(); 194 var updated = new AssetSet();
194 var futures = []; 195 var futures = [];
195 for (var id in changes.updated) { 196 for (var id in changes.updated) {
196 // TODO(rnystrom): Catch all errors from provider and route to results. 197 // TODO(rnystrom): Catch all errors from provider and route to results.
197 futures.add(_provider.getAsset(id).then((asset) { 198 futures.add(_provider.getAsset(id).then((asset) {
198 updated[id] = asset; 199 updated.add(asset);
199 }).catchError((error) { 200 }).catchError((error) {
200 if (error is AssetNotFoundException) { 201 if (error is AssetNotFoundException) {
201 // Handle missing asset errors like regular missing assets. 202 // Handle missing asset errors like regular missing assets.
202 reportError(error); 203 reportError(error);
203 } else { 204 } else {
204 // It's an unexpected error, so rethrow it. 205 // It's an unexpected error, so rethrow it.
205 throw error; 206 throw error;
206 } 207 }
207 })); 208 }));
208 } 209 }
209 210
210 return Future.wait(futures).then((_) { 211 return Future.wait(futures).then((_) {
211 _phases.first.updateInputs(updated, changes.removed); 212 _phases.first.updateInputs(updated, changes.removed);
212 }); 213 });
213 }); 214 });
214 } 215 }
215 } 216 }
216 217
217 /// Used to report build results back from the asynchronous build process 218 /// Used to report build results back from the asynchronous build process
218 /// running in the background. 219 /// running in the background.
219 class BuildResult { 220 class BuildResult {
220 /// The error that occurred, or `null` if the result is not an error. 221 /// The error that occurred, or `null` if the result is not an error.
221 final error; 222 final error;
222 223
223 /// `true` if this result is for a successful build. 224 /// `true` if this result is for a successful build.
224 bool get succeeded => error == null; 225 bool get succeeded => error == null;
225 226
226 BuildResult([this.error]); 227 BuildResult([this.error]);
227 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698