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

Side by Side Diff: pkg/barback/lib/src/transformer/base_transform.dart

Issue 560293004: Properly handle barback logs after a transformer's been canceled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
« no previous file with comments | « pkg/barback/CHANGELOG.md ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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.transformer.base_transform; 5 library barback.transformer.base_transform;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../asset/asset_id.dart'; 9 import '../asset/asset_id.dart';
10 import '../graph/transform_node.dart'; 10 import '../graph/transform_node.dart';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 TransformLogger get logger => _logger; 42 TransformLogger get logger => _logger;
43 TransformLogger _logger; 43 TransformLogger _logger;
44 44
45 BaseTransform(this._node) { 45 BaseTransform(this._node) {
46 _logger = new TransformLogger((asset, level, message, span) { 46 _logger = new TransformLogger((asset, level, message, span) {
47 if (level == LogLevel.ERROR) _loggedError = true; 47 if (level == LogLevel.ERROR) _loggedError = true;
48 48
49 // If the log isn't already associated with an asset, use the primary. 49 // If the log isn't already associated with an asset, use the primary.
50 if (asset == null) asset = _node.info.primaryId; 50 if (asset == null) asset = _node.info.primaryId;
51 var entry = new LogEntry(_node.info, asset, level, message, span); 51 var entry = new LogEntry(_node.info, asset, level, message, span);
52 _onLogController.add(entry); 52
53 // The log controller can be closed while log entries are still coming in
54 // if the transformer is removed during [apply].
55 if (!_onLogController.isClosed) _onLogController.add(entry);
53 }); 56 });
54 } 57 }
55 58
56 /// Consume a primary input so that it doesn't get processed by future 59 /// Consume a primary input so that it doesn't get processed by future
57 /// phases or emitted once processing has finished. 60 /// phases or emitted once processing has finished.
58 /// 61 ///
59 /// Normally each primary input will automatically be forwarded unless the 62 /// Normally each primary input will automatically be forwarded unless the
60 /// transformer overwrites it by emitting an input with the same id. This 63 /// transformer overwrites it by emitting an input with the same id. This
61 /// allows the transformer to tell barback not to forward a primary input 64 /// allows the transformer to tell barback not to forward a primary input
62 /// even if it's not overwritten. 65 /// even if it's not overwritten.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 /// 106 ///
104 /// This will close any streams and release any resources that were allocated 107 /// This will close any streams and release any resources that were allocated
105 /// for the duration of the transformation. Unlike [done], this indicates that 108 /// for the duration of the transformation. Unlike [done], this indicates that
106 /// the transformation is no longer relevant; either it has returned, or 109 /// the transformation is no longer relevant; either it has returned, or
107 /// something external has preemptively invalidated its results. 110 /// something external has preemptively invalidated its results.
108 void cancel() { 111 void cancel() {
109 done(); 112 done();
110 transform._onLogController.close(); 113 transform._onLogController.close();
111 } 114 }
112 } 115 }
OLDNEW
« no previous file with comments | « pkg/barback/CHANGELOG.md ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698