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

Unified Diff: sdk/lib/io/io_sink.dart

Issue 13680002: StreamConsumer has an addStream and a close functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « sdk/lib/io/http_parser.dart ('k') | tests/lib/async/slow_consumer2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/io_sink.dart
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
index 71426da8f678ad427ff403e791961412241dfe97..a9ae101f6dc86cabf000d7008215c3b328bd59c2 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -37,6 +37,11 @@ abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
Future<T> consume(Stream<List<int>> stream);
/**
+ * Provide functionality for piping to the [IOSink].
+ */
+ Future<T> addStream(Stream<List<int>> stream);
+
+ /**
* Like [consume], but will not close the target when done.
*/
Future<T> writeStream(Stream<List<int>> stream);
Søren Gjesse 2013/04/05 05:23:19 The plan is then to remove this in a future CL? We
floitsch 2013/04/05 16:21:32 Done.
@@ -44,7 +49,9 @@ abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
/**
* Close the target.
*/
- void close();
+ // TODO(floitsch): Currently the future cannot be typed because it has
+ // hardcoded type Future<HttpClientResponse> in subclass HttpClientRequest.
+ Future close();
/**
* Get future that will complete when all data has been written to
@@ -134,17 +141,22 @@ class _IOSinkImpl<T> implements IOSink<T> {
}
Future<T> writeStream(Stream<List<int>> stream) {
+ return addStream(stream);
+ }
+
+ Future<T> addStream(Stream<List<int>> stream) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
return _fillFromStream(stream, unbind: true);
}
- void close() {
+ Future close() {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
_controller.close();
+ return _pipeFuture;
}
Future<T> get done {
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | tests/lib/async/slow_consumer2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698