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

Unified Diff: runtime/bin/socket_patch.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: Update comments. Created 7 years, 8 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 | « pkg/http/test/safe_http_server.dart ('k') | sdk/lib/async/stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index 0e9c25f9d499a5f95cd063c4ef5e39cbaa60103d..cb289e88459a478fc707cc4782c1817c4e2c35df 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -689,6 +689,34 @@ class _SocketStreamConsumer extends StreamConsumer<List<int>, Socket> {
return socket._doneFuture;
}
+ Future<Socket> addStream(Stream<List<int>> stream) {
+ Completer completer = new Completer<Socket>();
+ if (socket._raw != null) {
+ subscription = stream.listen(
+ (data) {
+ assert(!paused);
+ assert(buffer == null);
+ buffer = data;
+ offset = 0;
+ write();
+ },
+ onError: (error) {
+ socket._consumerDone(error);
+ completer.completeError(error.error, error.stackTrace);
+ },
+ onDone: () {
+ completer.complete(socket);
+ },
+ unsubscribeOnError: true);
+ }
+ return completer.future;
+ }
+
+ Future<Socket> close() {
+ socket._consumerDone();
+ return completer.future;
+ }
+
void write() {
try {
if (subscription == null) return;
« no previous file with comments | « pkg/http/test/safe_http_server.dart ('k') | sdk/lib/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698