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

Unified Diff: runtime/bin/input_stream.dart

Issue 8818009: Add chunked input stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years 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 | « runtime/bin/chunked_stream.dart ('k') | tests/standalone/src/ChunkedStreamTest.dart » ('j') | no next file with comments »
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 0f009a33a53069641b3f9edef9513a5ddf5ee51f..300f50e77b52010292bf00930022ec22df2edf90 100644
--- a/runtime/bin/input_stream.dart
+++ b/runtime/bin/input_stream.dart
@@ -115,6 +115,57 @@ interface StringInputStream factory _StringInputStream {
}
+interface ChunkedInputStream factory _ChunkedInputStream {
+ /**
+ * Adds buffering to an input stream and provide the ability to read
+ * the data in known size chunks.
+ */
+ ChunkedInputStream(InputStream input, [int chunkSize]);
+
+ /**
+ * Reads [chunkSize] bytes from the stream. If [chunkSize] bytes are
+ * not currently available null is returned. When the stream is
+ * closed the last call can return with less than [chunkSize] bytes.
+ */
+ List<int> read();
+
+ /**
+ * Returns whether the stream has been closed. There might still be
+ * more data to read.
+ */
+ bool get closed();
+
+ /**
+ * Returns the chunk size used by this stream.
+ */
+ int get chunkSize();
+
+ /**
+ * Sets the chunk size used by this stream.
+ */
+ void set chunkSize(int chunkSize);
+
+ /**
+ * Sets the handler that gets called when at least [chunkSize] bytes
+ * of data is available or the underlying stream has been closed and
+ * there is still unread data.
+ */
+ void set dataHandler(void callback());
+
+ /**
+ * Sets the handler that gets called when there will be no more data
+ * available in the stream.
+ */
+ void set closeHandler(void callback());
+
+ /**
+ * Sets the handler that gets called when the underlying
+ * communication channel gets into some kind of error situation.
+ */
+ void set errorHandler(void callback());
+}
+
+
class StreamException implements Exception {
const StreamException([String this.message = ""]);
String toString() => "StreamException: $message";
« no previous file with comments | « runtime/bin/chunked_stream.dart ('k') | tests/standalone/src/ChunkedStreamTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698