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

Unified Diff: tools/dom/src/EventStreamProvider.dart

Issue 24509004: Run DOM callbacks in the zone they are coming from. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Wrap into expectAsync0. Created 7 years, 3 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
« tests/html/events_test.dart ('K') | « tests/html/events_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/EventStreamProvider.dart
diff --git a/tools/dom/src/EventStreamProvider.dart b/tools/dom/src/EventStreamProvider.dart
index a9c293da5da7083b938ffbd80785bdea4cf32068..5d6c0daac11dca4a919236215a02e987e8dc911b 100644
--- a/tools/dom/src/EventStreamProvider.dart
+++ b/tools/dom/src/EventStreamProvider.dart
@@ -154,11 +154,17 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
var _onData;
final bool _useCapture;
- _EventStreamSubscription(this._target, this._eventType, this._onData,
- this._useCapture) {
+ _EventStreamSubscription(this._target, this._eventType, onData,
+ this._useCapture) : _onData = _wrapZone(onData) {
_tryResume();
}
+ static _wrapZone(callback) {
+ // For performance reasons avoid wrapping if we are in the root zone.
+ if (Zone.current == Zone.ROOT) return callback;
+ return Zone.current.bindUnaryCallback(callback);
+ }
+
void cancel() {
if (_canceled) return;
@@ -177,7 +183,7 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
// Remove current event listener.
_unlisten();
- _onData = handleData;
+ _onData = _wrapZone(handleData);
_tryResume();
}
« tests/html/events_test.dart ('K') | « tests/html/events_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698