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 /** Abstract and private interface for a place to put events. */ | 7 /** Abstract and private interface for a place to put events. */ |
8 abstract class _EventSink<T> { | 8 abstract class _EventSink<T> { |
9 void _add(T data); | 9 void _add(T data); |
10 void _addError(Object error); | 10 void _addError(Object error); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 329 } |
330 | 330 |
331 void _sendError(var error) { | 331 void _sendError(var error) { |
332 assert(!_isCanceled); | 332 assert(!_isCanceled); |
333 assert(!_isPaused); | 333 assert(!_isPaused); |
334 assert(!_inCallback); | 334 assert(!_inCallback); |
335 bool wasInputPaused = _isInputPaused; | 335 bool wasInputPaused = _isInputPaused; |
336 _state |= _STATE_IN_CALLBACK; | 336 _state |= _STATE_IN_CALLBACK; |
337 if (!_zone.inSameErrorZone(Zone.current)) { | 337 if (!_zone.inSameErrorZone(Zone.current)) { |
338 // Errors are not allowed to traverse zone boundaries. | 338 // Errors are not allowed to traverse zone boundaries. |
339 Zone.current.handleUncaughtError(error); | 339 Zone.current.handleUncaughtError(error, getAttachedStackTrace(error)); |
340 } else { | 340 } else { |
341 _zone.runUnaryGuarded(_onError, error); | 341 _zone.runUnaryGuarded(_onError, error); |
342 } | 342 } |
343 _state &= ~_STATE_IN_CALLBACK; | 343 _state &= ~_STATE_IN_CALLBACK; |
344 if (_cancelOnError) { | 344 if (_cancelOnError) { |
345 _cancel(); | 345 _cancel(); |
346 } | 346 } |
347 _checkState(wasInputPaused); | 347 _checkState(wasInputPaused); |
348 } | 348 } |
349 | 349 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 524 |
525 // Types of the different handlers on a stream. Types used to type fields. | 525 // Types of the different handlers on a stream. Types used to type fields. |
526 typedef void _DataHandler<T>(T value); | 526 typedef void _DataHandler<T>(T value); |
527 typedef void _ErrorHandler(error); | 527 typedef void _ErrorHandler(error); |
528 typedef void _DoneHandler(); | 528 typedef void _DoneHandler(); |
529 | 529 |
530 | 530 |
531 /** Default data handler, does nothing. */ | 531 /** Default data handler, does nothing. */ |
532 void _nullDataHandler(var value) {} | 532 void _nullDataHandler(var value) {} |
533 | 533 |
534 /** Default error handler, reports the error to the global handler. */ | 534 /** Default error handler, reports the error to the current zone's handler. */ |
535 void _nullErrorHandler(error) { | 535 void _nullErrorHandler(error) { |
536 Zone.current.handleUncaughtError(error); | 536 Zone.current.handleUncaughtError(error, getAttachedStackTrace(error)); |
537 } | 537 } |
538 | 538 |
539 /** Default done handler, does nothing. */ | 539 /** Default done handler, does nothing. */ |
540 void _nullDoneHandler() {} | 540 void _nullDoneHandler() {} |
541 | 541 |
542 | 542 |
543 /** A delayed event on a buffering stream subscription. */ | 543 /** A delayed event on a buffering stream subscription. */ |
544 abstract class _DelayedEvent { | 544 abstract class _DelayedEvent { |
545 /** Added as a linked list on the [StreamController]. */ | 545 /** Added as a linked list on the [StreamController]. */ |
546 _DelayedEvent next; | 546 _DelayedEvent next; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 _Future<bool> hasNext = _futureOrPrefetch; | 995 _Future<bool> hasNext = _futureOrPrefetch; |
996 _clear(); | 996 _clear(); |
997 hasNext._complete(false); | 997 hasNext._complete(false); |
998 return; | 998 return; |
999 } | 999 } |
1000 _subscription.pause(); | 1000 _subscription.pause(); |
1001 _futureOrPrefetch = null; | 1001 _futureOrPrefetch = null; |
1002 _state = _STATE_EXTRA_DONE; | 1002 _state = _STATE_EXTRA_DONE; |
1003 } | 1003 } |
1004 } | 1004 } |
OLD | NEW |