Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: runtime/bin/output_stream.dart

Issue 8413034: New OutputStream interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 *
11 * An output stream provides internal buffering of the data written
12 * through all calls to [write] and [writeFrom] if data cannot be
13 * written immediately to the communication channel. The callback set
14 * through [noPendingWriteHandler] can be used to to keep the rate of
15 * writing in sync with the rate the system can actually write data to
16 * the underlying communication channel.
10 */ 17 */
11 interface OutputStream { 18 interface OutputStream {
12 /** 19 /**
13 * Writes [len] bytes into [buffer] buffer starting at [offset] offset]. 20 * Writes the content of [buffer] to the stream. This will pass
14 * If write succeedes true is returned. Otherwise false is returned 21 * ownership of the specified buffer to the system and the caller
15 * and [callback] callback is invoked on completion. 22 * should not change it. Returns true if the data could be written
23 * to the underlying communication channel immediately. Otherwise
24 * the data is buffered by the output stream and will be send as
25 * soon as possible.
16 */ 26 */
17 bool write(List<int> buffer, int offset, int len, void callback()); 27 bool write(List<int> buffer);
28
29 /**
30 * Writes [len] bytes from buffer [buffer] starting at offset
31 * [offset] to the output stream. If [offset] is not specified the
32 * default is 0. If [len] is not specified the default is the length
33 * of the buffer passed. The system will copy the data to be written
34 * so the caller can safely change [buffer] afterwards. Returns true
35 * if the data could be written to the underlying communication
36 * channel immediately. Otherwise the data is buffered by the output
37 * stream and will be send as soon as possible.
38 */
39 bool writeFrom(List<int> buffer, [int offset, int len]);
40
41 /**
42 * Indicate that all data has been written to the output
43 * stream. When all data has been written to communication channel
44 * it will be closed.
45 */
46 void end();
47
48 /**
49 * Close the communication channel immediately ignoring any buffered
50 * data.
51 */
52 void close();
53
54 /**
55 * The no pending write handler gets called when the internal OS
56 * buffers have been flushed. This callback can be used to keep the
57 * rate of writing in sync with the rate the system can write data
58 * to the underlying communication channel.
59 */
60 void set noPendingWriteHandler(void callback());
61
62 /*
63 * The close handler gets called when the underlying communication
64 * channel have been closed.
65 */
66 void set closeHandler(void callback());
67
68 /**
69 * The error handler gets called when the underlying communication
70 * channel gets into some kind of error situation.
71 */
72 void set errorHandler(void callback());
18 } 73 }
19 74
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698