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

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

Issue 11819030: Add onClosed callbacks to HTTP output streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | tests/standalone/io/http_stream_close_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 841a614674acb88976deca0d2a23e3db31570748..aac009359ecfbb693175a7a4370858f0bba53343 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -500,6 +500,9 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
_writeDone();
// Indicate to the connection that the response handling is done.
_httpConnection._responseClosed();
+ if (_streamClosedHandler != null) {
+ new Timer(0, (_) => _streamClosedHandler());
+ }
}
void _streamSetNoPendingWriteHandler(callback()) {
@@ -508,8 +511,8 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
}
}
- void _streamSetCloseHandler(callback()) {
- // TODO(sgjesse): Handle this.
+ void _streamSetClosedHandler(callback()) {
+ _streamClosedHandler = callback;
}
void _streamSetErrorHandler(callback(e)) {
@@ -621,6 +624,7 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
int _statusCode; // Response status code.
String _reasonPhrase; // Response reason phrase.
_HttpOutputStream _outputStream;
+ Function _streamClosedHandler;
Function _streamErrorHandler;
}
@@ -699,7 +703,7 @@ class _HttpOutputStream extends _BaseOutputStream implements OutputStream {
}
void set onClosed(void callback()) {
- _requestOrResponse._streamSetCloseHandler(callback);
+ _requestOrResponse._streamSetClosedHandler(callback);
}
void set onError(void callback(e)) {
@@ -1199,6 +1203,9 @@ class _HttpClientRequest
// Ensure that any trailing data is written.
_writeDone();
_connection._requestClosed();
+ if (_streamClosedHandler != null) {
+ new Timer(0, (_) => _streamClosedHandler());
+ }
}
void _streamSetNoPendingWriteHandler(callback()) {
@@ -1207,8 +1214,8 @@ class _HttpClientRequest
}
}
- void _streamSetCloseHandler(callback()) {
- // TODO(sgjesse): Handle this.
+ void _streamSetClosedHandler(callback()) {
+ _streamClosedHandler = callback;
}
void _streamSetErrorHandler(callback(e)) {
@@ -1265,6 +1272,7 @@ class _HttpClientRequest
Uri _uri;
_HttpClientConnection _connection;
_HttpOutputStream _outputStream;
+ Function _streamClosedHandler;
Function _streamErrorHandler;
bool _emptyBody = true;
}
« no previous file with comments | « no previous file | tests/standalone/io/http_stream_close_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698