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

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: Extend test. 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Future<T> get done { 78 Future<T> get done {
79 _controller; 79 _controller;
80 return _pipeFuture.then((_) => this); 80 return _pipeFuture.then((_) => this);
81 } 81 }
82 82
83 StreamController<List<int>> get _controller { 83 StreamController<List<int>> get _controller {
84 if (_controllerInstance == null) { 84 if (_controllerInstance == null) {
85 _controllerInstance = new StreamController<List<int>>( 85 _controllerInstance = new StreamController<List<int>>(
86 onPauseStateChange: _onPauseStateChange, 86 onPauseStateChange: _onPauseStateChange,
87 onSubscriptionStateChange: _onSubscriptionStateChange); 87 onSubscriptionStateChange: _onSubscriptionStateChange);
88 _pipeFuture = _controller.stream.pipe(_target); 88 _pipeFuture = _controller.stream.pipe(_target).then((_) => this);
89 } 89 }
90 return _controllerInstance; 90 return _controllerInstance;
91 } 91 }
92 92
93 bool get _isBound => _bindSubscription != null; 93 bool get _isBound => _bindSubscription != null;
94 94
95 void _onPauseStateChange() { 95 void _onPauseStateChange() {
96 _paused = _controller.isPaused; 96 _paused = _controller.isPaused;
97 if (_controller.isPaused) { 97 if (_controller.isPaused) {
98 _pause(); 98 _pause();
(...skipping 33 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.then((_) => this);
167 } 171 }
168 } 172 }
169 } 173 }
OLDNEW
« 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