Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 class _BroadcastStream<T> extends _ControllerStream<T> { | 7 class _BroadcastStream<T> extends _ControllerStream<T> { |
| 8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller); | 8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller); |
| 9 | 9 |
| 10 bool get isBroadcast => true; | 10 bool get isBroadcast => true; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 assert(_isAddingStream); | 231 assert(_isAddingStream); |
| 232 return new StateError("Cannot add new events while doing an addStream"); | 232 return new StateError("Cannot add new events while doing an addStream"); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void add(T data) { | 235 void add(T data) { |
| 236 if (!_mayAddEvent) throw _addEventError(); | 236 if (!_mayAddEvent) throw _addEventError(); |
| 237 _sendData(data); | 237 _sendData(data); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void addError(Object error, [StackTrace stackTrace]) { | 240 void addError(Object error, [StackTrace stackTrace]) { |
| 241 if (error == null) throw new ArgumentError("Error must not be null"); | |
|
floitsch
2014/09/24 12:59:14
Or make it an asynchronous NullThrownError?
Lasse Reichstein Nielsen
2014/09/24 13:49:57
I can do that everywhere. It would be consistent b
| |
| 241 if (!_mayAddEvent) throw _addEventError(); | 242 if (!_mayAddEvent) throw _addEventError(); |
| 242 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); | 243 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
|
Søren Gjesse
2014/09/24 13:29:31
The five lines seems to be duplicated in a number
Lasse Reichstein Nielsen
2014/09/24 13:49:57
I wish that I could, but it really just conditiona
| |
| 243 if (replacement != null) { | 244 if (replacement != null) { |
| 244 error = replacement.error; | 245 error = replacement.error; |
| 246 if (error == null) error = new NullThrownError(); | |
| 245 stackTrace = replacement.stackTrace; | 247 stackTrace = replacement.stackTrace; |
| 246 } | 248 } |
| 247 _sendError(error, stackTrace); | 249 _sendError(error, stackTrace); |
| 248 } | 250 } |
| 249 | 251 |
| 250 Future close() { | 252 Future close() { |
| 251 if (isClosed) { | 253 if (isClosed) { |
| 252 assert(_doneFuture != null); | 254 assert(_doneFuture != null); |
| 253 return _doneFuture; | 255 return _doneFuture; |
| 254 } | 256 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 _pauseCount++; | 504 _pauseCount++; |
| 503 } | 505 } |
| 504 void resume() { _resume(null); } | 506 void resume() { _resume(null); } |
| 505 void _resume(_) { | 507 void _resume(_) { |
| 506 if (_pauseCount > 0) _pauseCount--; | 508 if (_pauseCount > 0) _pauseCount--; |
| 507 } | 509 } |
| 508 Future cancel() { return new _Future.immediate(null); } | 510 Future cancel() { return new _Future.immediate(null); } |
| 509 bool get isPaused => _pauseCount > 0; | 511 bool get isPaused => _pauseCount > 0; |
| 510 Future asFuture([Object value]) => new _Future(); | 512 Future asFuture([Object value]) => new _Future(); |
| 511 } | 513 } |
| OLD | NEW |