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

Unified Diff: sdk/lib/js/dartium/js_dartium.dart

Issue 222203009: Execute callbacks from JS in the correct zone Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add _wrapToJs Created 6 years, 8 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/js/dart2js/js_dart2js.dart ('k') | tests/html/js_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/js/dartium/js_dartium.dart
diff --git a/sdk/lib/js/dartium/js_dartium.dart b/sdk/lib/js/dartium/js_dartium.dart
index e7f3004c686d8efbc0b5bdc038bbb28178f2f5d2..69f272d20c93b2ea0d0cdbc0ac6d8c383f5b48e0 100644
--- a/sdk/lib/js/dartium/js_dartium.dart
+++ b/sdk/lib/js/dartium/js_dartium.dart
@@ -87,6 +87,7 @@
*/
library dart.js;
+import 'dart:async' show Zone;
import 'dart:collection' show ListMixin;
import 'dart:nativewrappers';
@@ -360,6 +361,18 @@ class JsArray<E> extends JsObject with ListMixin<E> {
}
/**
+ * This function performs any wrapping of a Dart value before Dartium proxies
+ * it to JS.
+ */
+_wrapToJs(value) => value is Function ? _applyZoned(value) : value;
+
+_applyZoned(f) {
+ var call = (List arguments) => Function.apply(f, arguments);
+ if (Zone.current == Zone.ROOT) return call;
+ return Zone.current.bindUnaryCallback(call);
+}
+
+/**
* Placeholder object for cases where we need to determine exactly how many
* args were passed to a function.
*/
« no previous file with comments | « sdk/lib/js/dart2js/js_dart2js.dart ('k') | tests/html/js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698