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

Side by Side Diff: utils/pub/error_group.dart

Issue 14136004: Remove StreamController.broadcast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 error_group; 5 library error_group;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 class _ErrorGroupStream extends Stream { 218 class _ErrorGroupStream extends Stream {
219 /// The parent [ErrorGroup]. 219 /// The parent [ErrorGroup].
220 final ErrorGroup _group; 220 final ErrorGroup _group;
221 221
222 /// Whether [this] has completed, either successfully or with an error. 222 /// Whether [this] has completed, either successfully or with an error.
223 var _isDone = false; 223 var _isDone = false;
224 224
225 /// The underlying [StreamController] for [this]. 225 /// The underlying [StreamController] for [this].
226 final StreamController _controller; 226 final StreamController _controller;
227 227
228 /// The controller's [Stream]. May be different than `_controller.stream` if
229 /// the wrapped stream is a broadcasting stream.
230 Stream _stream;
231
228 /// The [StreamSubscription] that connects the wrapped [Stream] to 232 /// The [StreamSubscription] that connects the wrapped [Stream] to
229 /// [_controller]. 233 /// [_controller].
230 StreamSubscription _subscription; 234 StreamSubscription _subscription;
231 235
232 /// Whether [this] has any listeners. 236 /// Whether [this] has any listeners.
233 bool get _hasListeners => _controller.hasListener; 237 bool get _hasListeners => _controller.hasListener;
234 238
235 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps 239 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps
236 /// [inner]. 240 /// [inner].
237 _ErrorGroupStream(this._group, Stream inner) 241 _ErrorGroupStream(this._group, Stream inner)
238 : _controller = inner.isBroadcast ? 242 : _controller = new StreamController() {
239 new StreamController.broadcast() : 243 this.stream = isBroadcast
240 new StreamController() { 244 ? _controller.stream.asBroadcastStream()
245 : _controller.stream;
241 _subscription = inner.listen((v) { 246 _subscription = inner.listen((v) {
242 _controller.add(v); 247 _controller.add(v);
243 }, onError: (e) { 248 }, onError: (e) {
244 _group._signalError(e); 249 _group._signalError(e);
245 }, onDone: () { 250 }, onDone: () {
246 _isDone = true; 251 _isDone = true;
247 _group._signalStreamComplete(this); 252 _group._signalStreamComplete(this);
248 _controller.close(); 253 _controller.close();
249 }); 254 });
250 } 255 }
(...skipping 12 matching lines...) Expand all
263 void _signalError(AsyncError e) { 268 void _signalError(AsyncError e) {
264 if (_isDone) return; 269 if (_isDone) return;
265 _subscription.cancel(); 270 _subscription.cancel();
266 // Call these asynchronously to work around issue 7913. 271 // Call these asynchronously to work around issue 7913.
267 new Future.immediate(null).then((_) { 272 new Future.immediate(null).then((_) {
268 _controller.addError(e.error, e.stackTrace); 273 _controller.addError(e.error, e.stackTrace);
269 _controller.close(); 274 _controller.close();
270 }); 275 });
271 } 276 }
272 } 277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698