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

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

Issue 12317147: Implement addStream for HttpClientRequest/HttpResponse and propegate all write-errors from the sock… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Extend test. Created 7 years, 10 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_impl.dart ('k') | tests/standalone/io/http_request_pipeling_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/io_stream_consumer.dart
diff --git a/sdk/lib/io/io_stream_consumer.dart b/sdk/lib/io/io_stream_consumer.dart
index b2c76ac37445527395fa11c00325be424d1bdecb..9ae639e570af3428ec9c8c86920afda6339b9d3a 100644
--- a/sdk/lib/io/io_stream_consumer.dart
+++ b/sdk/lib/io/io_stream_consumer.dart
@@ -85,7 +85,7 @@ class IOSink<T> implements StreamConsumer<List<int>, T> {
_controllerInstance = new StreamController<List<int>>(
onPauseStateChange: _onPauseStateChange,
onSubscriptionStateChange: _onSubscriptionStateChange);
- _pipeFuture = _controller.stream.pipe(_target);
+ _pipeFuture = _controller.stream.pipe(_target).then((_) => this);
}
return _controllerInstance;
}
@@ -139,15 +139,22 @@ class IOSink<T> implements StreamConsumer<List<int>, T> {
if (unbind) {
unbindCompleter = new Completer<T>();
}
+ completeUnbind([error]) {
+ if (unbindCompleter == null) return;
+ var tmp = unbindCompleter;
+ unbindCompleter = null;
+ if (error == null) {
+ _bindSubscription = null;
+ tmp.complete();
+ } else {
+ tmp.completeError(error);
+ }
+ }
_bindSubscription = stream.listen(
_controller.add,
onDone: () {
- _bindSubscription = null;
if (unbind) {
- if (unbindCompleter != null) {
- unbindCompleter.complete(null);
- unbindCompleter = null;
- }
+ completeUnbind();
} else {
_controller.close();
}
@@ -155,15 +162,12 @@ class IOSink<T> implements StreamConsumer<List<int>, T> {
onError: _controller.signalError);
if (_paused) _pause();
if (unbind) {
- _pipeFuture.catchError((error) {
- if (unbindCompleter != null) {
- unbindCompleter.completeError(error);
- unbindCompleter = null;
- }
- });
+ _pipeFuture
+ .then((_) => completeUnbind(),
+ onError: (error) => completeUnbind(error));
return unbindCompleter.future;
} else {
- return _pipeFuture;
+ return _pipeFuture.then((_) => this);
}
}
}
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/http_request_pipeling_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698