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

Unified Diff: sdk/lib/async/zone.dart

Issue 25002002: Add a default value for bindCallback's runGuarded. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/zone.dart
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
index ac6bacd2361b60e9b607fed5a16ed3cc8f04cf14..4f067dd7fdecd75efac0bf4730f03499ab2ed8f1 100644
--- a/sdk/lib/async/zone.dart
+++ b/sdk/lib/async/zone.dart
@@ -251,23 +251,44 @@ abstract class Zone {
*/
dynamic runUnaryGuarded(f(arg), var arg);
- ZoneCallback registerCallback(f());
- ZoneUnaryCallback registerUnaryCallback(f(arg));
+ /**
+ * Registers the given callback in this zone.
+ *
+ * It is good practice to register asynchronous or delayed callbacks before
+ * invoking [run]. This gives the zone a chance to wrap the callback and
+ * to store information with the callback. For example, a zone may decide
+ * to store the stack trace (at the time of the registration) with the
+ * callback.
+ *
+ * Returns a potentially new callback that should be used in place of the
+ * given [callback].
+ */
+ ZoneCallback registerCallback(callback());
+
+ /**
+ * Registers the given callback in this zone.
+ *
+ * Similar to [registerCallback] but with a unary callback.
+ */
+ ZoneUnaryCallback registerUnaryCallback(callback(arg));
/**
* Equivalent to:
*
* ZoneCallback registered = registerCallback(f);
+ * if (runGuarded) return () => this.runGuarded(registered);
* return () => this.run(registered);
+ *
*/
- ZoneCallback bindCallback(f(), { bool runGuarded });
+ ZoneCallback bindCallback(f(), { bool runGuarded: true });
/**
* Equivalent to:
*
* ZoneCallback registered = registerCallback1(f);
- * return (arg) => this.run1(registered, arg);
+ * if (runGuarded) return (arg) => this.runUnaryGuarded(registered, arg);
+ * return (arg) => thin.runUnary(registered, arg);
*/
- ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded });
+ ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true });
/**
* Runs [f] asynchronously.
@@ -427,7 +448,7 @@ class _CustomizedZone implements Zone {
}
}
- ZoneCallback bindCallback(f(), { bool runGuarded }) {
+ ZoneCallback bindCallback(f(), { bool runGuarded: true }) {
ZoneCallback registered = registerCallback(f);
if (runGuarded) {
return () => this.runGuarded(registered);
@@ -436,7 +457,7 @@ class _CustomizedZone implements Zone {
}
}
- ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded }) {
+ ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true }) {
ZoneUnaryCallback registered = registerUnaryCallback(f);
if (runGuarded) {
return (arg) => this.runUnaryGuarded(registered, arg);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698