| OLD | NEW |
| 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 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Wraps an [_EventSink] so it exposes only the [EventSink] interface. | 8 * Wraps an [_EventSink] so it exposes only the [EventSink] interface. |
| 9 */ | 9 */ |
| 10 class _EventSinkWrapper<T> implements EventSink<T> { | 10 class _EventSinkWrapper<T> implements EventSink<T> { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 StreamSubscription subscription = _subscription; | 107 StreamSubscription subscription = _subscription; |
| 108 _subscription = null; | 108 _subscription = null; |
| 109 subscription.cancel(); | 109 subscription.cancel(); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void _handleData(S data) { | 113 void _handleData(S data) { |
| 114 try { | 114 try { |
| 115 _transformerSink.add(data); | 115 _transformerSink.add(data); |
| 116 } catch (e, s) { | 116 } catch (e, s) { |
| 117 _addError(_asyncError(e, s), s); | 117 _addError(e, s); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 void _handleError(error, [stackTrace]) { | 121 void _handleError(error, [stackTrace]) { |
| 122 try { | 122 try { |
| 123 _transformerSink.addError(error, stackTrace); | 123 _transformerSink.addError(error, stackTrace); |
| 124 } catch (e, s) { | 124 } catch (e, s) { |
| 125 if (identical(e, error)) { | 125 if (identical(e, error)) { |
| 126 _addError(error, stackTrace); | 126 _addError(error, stackTrace); |
| 127 } else { | 127 } else { |
| 128 _addError(_asyncError(e, s), s); | 128 _addError(e, s); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 void _handleDone() { | 133 void _handleDone() { |
| 134 try { | 134 try { |
| 135 _subscription = null; | 135 _subscription = null; |
| 136 _transformerSink.close(); | 136 _transformerSink.close(); |
| 137 } catch (e, s) { | 137 } catch (e, s) { |
| 138 _addError(_asyncError(e, s), s); | 138 _addError(e, s); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 typedef EventSink<S> _SinkMapper<S, T>(EventSink<T> output); | 144 typedef EventSink<S> _SinkMapper<S, T>(EventSink<T> output); |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * A StreamTransformer for Sink-mappers. | 147 * A StreamTransformer for Sink-mappers. |
| 148 * | 148 * |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 void onDone(), | 305 void onDone(), |
| 306 bool cancelOnError }) { | 306 bool cancelOnError }) { |
| 307 cancelOnError = identical(true, cancelOnError); | 307 cancelOnError = identical(true, cancelOnError); |
| 308 StreamSubscription<T> result = _transformer(_stream, cancelOnError); | 308 StreamSubscription<T> result = _transformer(_stream, cancelOnError); |
| 309 result.onData(onData); | 309 result.onData(onData); |
| 310 result.onError(onError); | 310 result.onError(onError); |
| 311 result.onDone(onDone); | 311 result.onDone(onDone); |
| 312 return result; | 312 return result; |
| 313 } | 313 } |
| 314 } | 314 } |
| OLD | NEW |