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.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide | 8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide |
9 * utility functions for writing to the StreamConsumer directly. The | 9 * utility functions for writing to the StreamConsumer directly. The |
10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], | 10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 _bindSubscription = null; | 187 _bindSubscription = null; |
188 tmp.complete(); | 188 tmp.complete(); |
189 } else { | 189 } else { |
190 tmp.completeError(error); | 190 tmp.completeError(error); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 StreamController<List<int>> get _controller { | 194 StreamController<List<int>> get _controller { |
195 if (_controllerInstance == null) { | 195 if (_controllerInstance == null) { |
196 _controllerInstance = new StreamController<List<int>>( | 196 _controllerInstance = new StreamController<List<int>>( |
197 onPauseStateChange: _onPauseStateChange, | 197 onListen: _onSubscriptionStateChange, |
198 onSubscriptionStateChange: _onSubscriptionStateChange); | 198 onPause: _onPauseStateChange, |
| 199 onResume: _onPauseStateChange, |
| 200 onCancel: _onSubscriptionStateChange); |
199 var future = _controller.stream.pipe(_target); | 201 var future = _controller.stream.pipe(_target); |
200 future.then((_) => _completeWriteStreamCompleter(), | 202 future.then((_) => _completeWriteStreamCompleter(), |
201 onError: (error) => _completeWriteStreamCompleter(error)); | 203 onError: (error) => _completeWriteStreamCompleter(error)); |
202 _pipeFuture = future.then((value) => value); | 204 _pipeFuture = future.then((value) => value); |
203 } | 205 } |
204 return _controllerInstance; | 206 return _controllerInstance; |
205 } | 207 } |
206 | 208 |
207 bool get _isBound => _bindSubscription != null; | 209 bool get _isBound => _bindSubscription != null; |
208 | 210 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 }, | 266 }, |
265 onError: _controller.addError); | 267 onError: _controller.addError); |
266 if (_paused) _pause(); | 268 if (_paused) _pause(); |
267 if (unbind) { | 269 if (unbind) { |
268 return _writeStreamCompleter.future; | 270 return _writeStreamCompleter.future; |
269 } else { | 271 } else { |
270 return _pipeFuture; | 272 return _pipeFuture; |
271 } | 273 } |
272 } | 274 } |
273 } | 275 } |
OLD | NEW |