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

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

Issue 11853011: Reapply "Add onClosed callbacks to HTTP output streams"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debug print 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
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 9bf97008d3498a1c30634e8e53f8d1b1379b3bb7..08451ab61b03e7fe00b111f86b0c8f8b624203ac 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -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') | tests/standalone/io/http_stream_close_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698