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

Unified Diff: runtime/bin/socket_patch.dart

Issue 93973002: Add test of Zones for HttpServer and RawSocketServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Stay in zone in raw socket/serversocket. Created 7 years, 1 month 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_server_test.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 1480f1f97b41ef2331744cca1e9313d799dddfc4..48265f7eede4719207f6eff7432345559e956677 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -737,6 +737,7 @@ class _RawServerSocket extends Stream<RawSocket>
}
_RawServerSocket(this._socket) {
+ var zone = Zone.current;
_controller = new StreamController(sync: true,
onListen: _onSubscriptionStateChange,
onCancel: _onSubscriptionStateChange,
@@ -744,14 +745,14 @@ class _RawServerSocket extends Stream<RawSocket>
onResume: _onPauseStateChange);
_socket.closeFuture.then((_) => _controller.close());
_socket.setHandlers(
- read: () {
+ read: zone.bindCallback(() {
var socket = _socket.accept();
if (socket != null) _controller.add(new _RawSocket(socket));
- },
- error: (e) {
+ }),
+ error: zone.bindUnaryCallback((e) {
_controller.addError(e);
_controller.close();
- }
+ })
);
}
@@ -814,6 +815,7 @@ class _RawSocket extends Stream<RawSocketEvent>
}
_RawSocket(this._socket) {
+ var zone = Zone.current;
_controller = new StreamController(sync: true,
onListen: _onSubscriptionStateChange,
onCancel: _onSubscriptionStateChange,
@@ -830,10 +832,10 @@ class _RawSocket extends Stream<RawSocketEvent>
},
closed: () => _controller.add(RawSocketEvent.READ_CLOSED),
destroyed: () => _controller.add(RawSocketEvent.CLOSED),
- error: (e) {
+ error: zone.bindUnaryCallback((e) {
_controller.addError(e);
close();
- }
+ })
);
}
« no previous file with comments | « no previous file | tests/standalone/io/http_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698