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

Side by Side Diff: pkg/barback/lib/src/graph/static_asset_cascade.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.graph.static_asset_cascade;
6
7 import 'dart:async';
8
9 import '../asset/asset_id.dart';
10 import '../asset/asset_node.dart';
11 import '../asset/asset_set.dart';
12 import '../errors.dart';
13 import '../log.dart';
14 import '../package_provider.dart';
15 import 'asset_cascade.dart';
16 import 'node_status.dart';
17 import 'package_graph.dart';
18
19 /// An asset cascade for a static package.
20 ///
21 /// A static package is known to have no transformers and no changes to its
22 /// assets. This allows this class to lazily and efficiently provide assets to
23 /// the rest of the package graph.
24 class StaticAssetCascade implements AssetCascade {
25 final String package;
26
27 final PackageGraph graph;
28
29 /// All sources that have been requested from the provider.
30 final _sources = new Map<AssetId, Future<AssetNode>>();
31
32 StaticAssetCascade(this.graph, this.package);
33
34 Stream<BarbackException> get errors => _errorsController.stream;
35 final _errorsController =
36 new StreamController<BarbackException>.broadcast(sync: true);
37
38 final status = NodeStatus.IDLE;
39
40 final onLog = new StreamController<LogEntry>.broadcast().stream;
41 final onStatusChange = new StreamController<LogEntry>.broadcast().stream;
42
43 Future<AssetSet> get availableOutputs {
44 var provider = graph.provider as StaticPackageProvider;
45 return provider.getAllAssetIds(package).asyncMap(provider.getAsset).toList()
46 .then((assets) => new AssetSet.from(assets));
47 }
48
49 Future<AssetNode> getAssetNode(AssetId id) {
50 return _sources.putIfAbsent(id, () {
51 return graph.provider.getAsset(id).then((asset) {
52 return new AssetNodeController.available(asset).node;
53 }).catchError((error, stackTrace) {
54 if (error is! AssetNotFoundException) {
55 reportError(new AssetLoadException(id, error, stackTrace));
56 }
57
58 // TODO(nweiz): propagate error information through asset nodes.
59 return null;
60 });
61 });
62 }
63
64 void updateSources(Iterable<AssetId> sources) =>
65 throw new UnsupportedError("Static package $package can't be explicitly "
66 "provided sources.");
67
68 void removeSources(Iterable<AssetId> sources) =>
69 throw new UnsupportedError("Static package $package can't be explicitly "
70 "provided sources.");
71
72 void updateTransformers(Iterable<Iterable> transformersIterable) =>
73 throw new UnsupportedError("Static package $package can't have "
74 "transformers.");
75
76 void forceAllTransforms() {}
77
78 void reportError(BarbackException error) => _errorsController.add(error);
79
80 String toString() => "static cascade for $package";
81 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/graph/phase_output.dart ('k') | pkg/barback/lib/src/graph/transform_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698