Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Output is written to a given output stream. Such an output stream can | 6 * Output is written to a given output stream. Such an output stream can |
| 7 * be an endpoint, e.g., a socket or a file, or another output stream. | 7 * be an endpoint, e.g., a socket or a file, or another output stream. |
| 8 * Multiple output streams can be chained together to operate collaboratively | 8 * Multiple output streams can be chained together to operate collaboratively |
| 9 * on a given output. | 9 * on a given output. |
| 10 */ | 10 */ |
| 11 interface OutputStream { | 11 interface OutputStream { |
| 12 /** | 12 /** |
| 13 * Writes [len] bytes into [buffer] buffer starting at [offset] offset]. | 13 * Writes [len] bytes from buffer [buffer] starting at offset [offset]. |
| 14 * If write succeedes true is returned. Otherwise false is returned | 14 * When write is finished the specified callback is called. |
| 15 * and [callback] callback is invoked on completion. | |
| 16 */ | 15 */ |
| 17 bool write(List<int> buffer, int offset, int len, void callback()); | 16 void WriteFully(List<int> buffer, int offset, int len, void callback()) |
|
sra1
2011/10/18 23:45:51
Why is this WriteFully, not writeFully?
Is this a
Søren Gjesse
2011/10/19 14:45:41
No, that is a mistake.
| |
| 17 | |
| 18 /** | |
| 19 * Writes up til [len] bytes from buffer [buffer] starting at offset | |
|
sra1
2011/10/18 23:45:51
'up til' --> 'up to'
| |
| 20 * [offset]. Returns the number of bytes written. If all data could not be | |
| 21 * written the specified callback is called when more data can be written. | |
|
sra1
2011/10/18 23:45:51
When the callback is called, has the data been wri
| |
| 22 */ | |
| 23 int write(List<int> buffer, int offset, int len, void callback()); | |
| 24 | |
| 25 /** | |
| 26 * Close the stream. This will normally also close the underlying | |
| 27 * communication channel. | |
| 28 */ | |
| 29 void close(); | |
| 30 | |
| 31 /** | |
| 32 * The close handler gets called when the underlying communication | |
| 33 * channel gets closed. Not all types of communication channels will | |
| 34 * emit close events. | |
| 35 */ | |
| 36 void set closeHandler(void callback()); | |
| 37 | |
| 38 /** | |
| 39 * The error handler gets called when the underlying communication | |
| 40 * channel gets into some kind of error situation. | |
| 41 */ | |
| 42 void set errorHandler(void callback(StreamError error)); | |
| 18 } | 43 } |
| 19 | 44 |
| 45 interface StringOutputStream { | |
| 46 /** | |
| 47 * Writes [len] bytes from buffer [buffer] starting at offset [offset]. | |
| 48 * When write is finished the specified callback is called. | |
| 49 */ | |
| 50 void WriteFully(String data, int offset, int len, void callback()) | |
| 51 | |
| 52 /** | |
| 53 * Writes up til [len] bytes from buffer [buffer] starting at offset | |
| 54 * [offset]. Returns the number of bytes written. If all data could not be | |
| 55 * written the specified callback is called when more data can be written. | |
| 56 */ | |
| 57 int write(String data, int offset, int len, void callback()); | |
| 58 | |
| 59 /** | |
| 60 * Sets the encoding to be used when writing string data to the | |
| 61 * stream. The default encoding is UTF-8. | |
| 62 */ | |
| 63 void set encoding(String encoding); | |
| 64 } | |
| 65 | |
| OLD | NEW |