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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide utility 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide utility
9 * functions for writing to the StreamConsumer directly. The [IOSink] 9 * functions for writing to the StreamConsumer directly. The [IOSink]
10 * buffers the input given by [add] and [addString] and will delay a [consume] 10 * buffers the input given by [add] and [addString] and will delay a [consume]
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 } 133 }
134 } 134 }
135 135
136 Future<T> _fillFromStream(Stream<List<int>> stream, {unbind: false}) { 136 Future<T> _fillFromStream(Stream<List<int>> stream, {unbind: false}) {
137 _controller; 137 _controller;
138 Completer<T> unbindCompleter; 138 Completer<T> unbindCompleter;
139 if (unbind) { 139 if (unbind) {
140 unbindCompleter = new Completer<T>(); 140 unbindCompleter = new Completer<T>();
141 } 141 }
142 completeUnbind([error]) {
143 if (unbindCompleter == null) return;
144 var tmp = unbindCompleter;
145 unbindCompleter = null;
146 if (error == null) {
147 _bindSubscription = null;
148 tmp.complete();
149 } else {
150 tmp.completeError(error);
151 }
152 }
142 _bindSubscription = stream.listen( 153 _bindSubscription = stream.listen(
143 _controller.add, 154 _controller.add,
144 onDone: () { 155 onDone: () {
145 _bindSubscription = null;
146 if (unbind) { 156 if (unbind) {
147 if (unbindCompleter != null) { 157 completeUnbind();
148 unbindCompleter.complete(null);
149 unbindCompleter = null;
150 }
151 } else { 158 } else {
152 _controller.close(); 159 _controller.close();
153 } 160 }
154 }, 161 },
155 onError: _controller.signalError); 162 onError: _controller.signalError);
156 if (_paused) _pause(); 163 if (_paused) _pause();
157 if (unbind) { 164 if (unbind) {
158 _pipeFuture.catchError((error) { 165 _pipeFuture
159 if (unbindCompleter != null) { 166 .then((_) => completeUnbind(),
160 unbindCompleter.completeError(error); 167 onError: (error) => completeUnbind(error));
161 unbindCompleter = null;
162 }
163 });
164 return unbindCompleter.future; 168 return unbindCompleter.future;
165 } else { 169 } else {
166 return _pipeFuture; 170 return _pipeFuture;
167 } 171 }
168 } 172 }
169 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698