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

Unified Diff: runtime/bin/input_stream.dart

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactored InputStream Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/output_stream.dart » ('j') | runtime/bin/output_stream.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/input_stream.dart
diff --git a/runtime/bin/input_stream.dart b/runtime/bin/input_stream.dart
index 48320138d136e70f4d746a33113404c3bbb1ee70..2847070982bbf21efeeaf0150cdf58bad041b294 100644
--- a/runtime/bin/input_stream.dart
+++ b/runtime/bin/input_stream.dart
@@ -10,15 +10,91 @@
*/
interface InputStream {
/**
- * Reads [len] bytes into [buffer] buffer starting at [offset] offset.
- * [callback] callback is invoked on completion unless it is null.
+ * Reads as much data as is available from the stream. If no data is
+ * available null will be returned.
*/
- bool read(List<int> buffer, int offset, int len, void callback());
+ List<int> read();
/**
- * Reads data from the stream into a buffer until a given [pattern] occurs and
- * hands that buffer over as an input to the registered [callback].
- * The callback is not invoked if a read error occurs.
+ * The data handler gets called when data is available.
*/
- void readUntil(List<int> pattern, void callback(List<int> buffer));
+ void set dataHandler(void callback());
sra1 2011/10/18 23:45:51 There is a subtle relationship between the number
Søren Gjesse 2011/10/19 14:45:41 That should hopefully be the case - unless the OS
+
+ /**
+ * The close handler gets called when the underlying communication
+ * channel is closed and no more data will become available. Not all
+ * types of communication channels will emit close events.
+ */
+ void set closeHandler(void callback());
+
+ /**
+ * The error handler gets called when the underlying communication
+ * channel gets into some kind of error situation.
+ */
+ void set errorHandler(void callback(StreamError error));
+}
+
+
+interface StringInputStream factory _StringInputStream {
dcarlson 2011/10/18 17:26:19 I'm surprised that it does not generate close/erro
Søren Gjesse 2011/10/19 14:45:41 No, it should also generate the close and error ev
+ /**
+ * Decodes a binary input stream into characters using the specified
+ * encoding.
+ */
+ StringInputStream(InputStream input, [String encoding = "UTF-8"]);
dcarlson 2011/10/18 17:26:19 Could we add a dataHandler as an optional param?
Søren Gjesse 2011/10/19 14:45:41 Maybe, but then we should also do that for the Inp
+
+ /**
+ * Reads as many characters as is available from the stream. If no data is
+ * available null will be returned.
+ */
+ String read();
+
+ /**
+ * Returns the encoding used to decode the binary data into characters.
+ */
+ String get encoding();
dcarlson 2011/10/18 17:26:19 Can the encoding be changed mid-stream?
Søren Gjesse 2011/10/19 14:45:41 No.
+
+ /**
+ * The data handler gets called when data is available.
+ */
+ void set dataHandler(void callback());
+}
+
+
+interface ProcessingInputStream factory _ProcessingInputStream {
+ ProcessingInputStream(InputStream input);
+
+ /**
+ * Reads [len] bytes from the stream. When the bytes have been read the
+ * specified [callback] is called with the data.
+ */
+ void readFully(int len, void callback(List<int> buffer));
+
+ /**
+ * Reads data from the stream into a buffer until the specified [pattern]
+ * occurs. When the pattern occours the specified [callback] is called with
+ * the data including the pattern. If the pattern is not found before
+ * [maxLength] bytes have been received the error handler will be called.
+ */
+ void readUntil(List<int> pattern,
+ void callback(List<int> buffer),
+ [int maxLength = -1]);
+
+ /**
+ * Reads as much data as is available from the stream. The supplied
+ * callback is called with the data.
+ */
+ void read(void callback(List<int> data));
+
+ /**
+ * The close handler gets called when the underlying communication
+ * channel gets closed. Not all types of communication channels will
+ * emit close events.
+ */
+ void set closeHandler(void callback());
sra1 2011/10/18 23:45:51 This implies that the underlying's closeHander set
Søren Gjesse 2011/10/19 14:45:41 My take on this is that if you wrap an InputStream
+
+ /**
+ * The error handler gets called when the underlying communication
+ * channel gets into some kind of error situation.
+ */
+ void set errorHandler(void callback(StreamError error));
}
« no previous file with comments | « no previous file | runtime/bin/output_stream.dart » ('j') | runtime/bin/output_stream.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698