| 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 all [StringSink] methods and will delay | 10 * [IOSink] buffers the input given by all [StringSink] methods and will delay |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 Encoding encoding; | 26 Encoding encoding; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Writes the bytes uninterpreted to the consumer. | 29 * Writes the bytes uninterpreted to the consumer. |
| 30 */ | 30 */ |
| 31 void add(List<int> data); | 31 void add(List<int> data); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Writes an error to the consumer. | 34 * Writes an error to the consumer. |
| 35 */ | 35 */ |
| 36 void addError(AsyncError error); | 36 void addError(error); |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * Adds all elements of the given [stream] to `this`. | 39 * Adds all elements of the given [stream] to `this`. |
| 40 */ | 40 */ |
| 41 Future addStream(Stream<List<int>> stream); | 41 Future addStream(Stream<List<int>> stream); |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Close the target. | 44 * Close the target. |
| 45 */ | 45 */ |
| 46 Future close(); | 46 Future close(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 void writeCharCode(int charCode) { | 118 void writeCharCode(int charCode) { |
| 119 write(new String.fromCharCode(charCode)); | 119 write(new String.fromCharCode(charCode)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void add(List<int> data) { | 122 void add(List<int> data) { |
| 123 _controller.add(data); | 123 _controller.add(data); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void addError(AsyncError error) { | 126 void addError(error) { |
| 127 _controller.addError(error); | 127 _controller.addError(error); |
| 128 } | 128 } |
| 129 | 129 |
| 130 Future addStream(Stream<List<int>> stream) { | 130 Future addStream(Stream<List<int>> stream) { |
| 131 if (_isBound) { | 131 if (_isBound) { |
| 132 throw new StateError("IOSink is already bound to a stream"); | 132 throw new StateError("IOSink is already bound to a stream"); |
| 133 } | 133 } |
| 134 _isBound = true; | 134 _isBound = true; |
| 135 // Wait for any sync operations to complete. | 135 // Wait for any sync operations to complete. |
| 136 Future targetAddStream() { | 136 Future targetAddStream() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } else { | 213 } else { |
| 214 // No new stream. No need to close target, as it have already | 214 // No new stream. No need to close target, as it have already |
| 215 // failed. | 215 // failed. |
| 216 _completeDone(error: error); | 216 _completeDone(error: error); |
| 217 } | 217 } |
| 218 }); | 218 }); |
| 219 } | 219 } |
| 220 return _controllerInstance; | 220 return _controllerInstance; |
| 221 } | 221 } |
| 222 } | 222 } |
| OLD | NEW |