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

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

Issue 2609633002: Make EventStreamSubscription DDC safe. (Closed)
Patch Set: Rebase Created 3 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/shared_html.dart » ('j') | 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 474a1431b9defe83d3cc156678d63c763044a1a9..9a75afde6b6cdae8a3816e79cb859da718e160d2 100644
--- a/tools/dom/src/EventStreamProvider.dart
+++ b/tools/dom/src/EventStreamProvider.dart
@@ -226,13 +226,21 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
EventListener _onData;
final bool _useCapture;
- // TODO(jacobr): for full strong mode correctness we should write
- // _onData = onData == null ? null : _wrapZone/*<Event, dynamic>*/((e) => onData(e as T))
- // but that breaks 114 co19 tests as well as multiple html tests as it is reasonable
- // to pass the wrong type of event object to an event listener as part of a
- // test.
+ // TODO(leafp): It would be better to write this as
+ // _onData = onData == null ? null :
+ // onData is _wrapZoneCallback<Event, dynamic>
+ // ? _wrapZone/*<Event, dynamic>*/(onData)
+ // : _wrapZone/*<Event, dynamic>*/((e) => onData(e as T))
+ // In order to support existing tests which pass the wrong type of events but
+ // use a more general listener, without causing as much slowdown for things
+ // which are typed correctly. But this currently runs afoul of restrictions
+ // on is checks for compatibility with the VM.
_EventStreamSubscription(this._target, this._eventType, void onData(T event),
- this._useCapture) : _onData = _wrapZone/*<Event, dynamic>*/(onData) {
+ this._useCapture) :
+ _onData = onData == null
+ ? null
+ : _wrapZone/*<Event, dynamic>*/((e) => (onData as dynamic)(e))
+ {
_tryResume();
}
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/shared_html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698