| 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>, T>] and provide | 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Future<T> _pipeFuture; | 62 Future<T> _pipeFuture; |
| 63 StreamSubscription<List<int>> _bindSubscription; | 63 StreamSubscription<List<int>> _bindSubscription; |
| 64 bool _paused = true; | 64 bool _paused = true; |
| 65 bool _encodingMutable = true; | 65 bool _encodingMutable = true; |
| 66 | 66 |
| 67 _IOSinkImpl(StreamConsumer<List<int>, T> this._target, this._encoding); | 67 _IOSinkImpl(StreamConsumer<List<int>, T> this._target, this._encoding); |
| 68 | 68 |
| 69 Encoding _encoding; | 69 Encoding _encoding; |
| 70 | 70 |
| 71 Encoding get encoding => _encoding; | 71 Encoding get encoding => _encoding; |
| 72 |
| 72 void set encoding(Encoding value) { | 73 void set encoding(Encoding value) { |
| 73 if (!_encodingMutable) { | 74 if (!_encodingMutable) { |
| 74 throw new StateError("IOSink encoding is not mutable"); | 75 throw new StateError("IOSink encoding is not mutable"); |
| 75 } | 76 } |
| 76 _encoding = value; | 77 _encoding = value; |
| 77 } | 78 } |
| 78 | 79 |
| 79 void write(Object obj) { | 80 void write(Object obj) { |
| 80 // This comment is copied from runtime/lib/string_buffer_patch.dart. | 81 // This comment is copied from runtime/lib/string_buffer_patch.dart. |
| 81 // TODO(srdjan): The following four lines could be replaced by | 82 // TODO(srdjan): The following four lines could be replaced by |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 }, | 225 }, |
| 225 onError: _controller.addError); | 226 onError: _controller.addError); |
| 226 if (_paused) _pause(); | 227 if (_paused) _pause(); |
| 227 if (unbind) { | 228 if (unbind) { |
| 228 return _writeStreamCompleter.future; | 229 return _writeStreamCompleter.future; |
| 229 } else { | 230 } else { |
| 230 return _pipeFuture.then((_) => this); | 231 return _pipeFuture.then((_) => this); |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 } | 234 } |
| OLD | NEW |