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

Side by Side Diff: sdk/lib/async/zone.dart

Issue 25027004: Add second argument to Future error handlers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | tests/lib/async/catch_errors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 typedef dynamic ZoneCallback(); 7 typedef dynamic ZoneCallback();
8 typedef dynamic ZoneUnaryCallback(arg); 8 typedef dynamic ZoneUnaryCallback(arg);
9 typedef dynamic ZoneBinaryCallback(arg1, arg2);
9 10
10 typedef dynamic HandleUncaughtErrorHandler( 11 typedef dynamic HandleUncaughtErrorHandler(
11 Zone self, ZoneDelegate parent, Zone zone, e); 12 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace);
12 typedef dynamic RunHandler(Zone self, ZoneDelegate parent, Zone zone, f()); 13 typedef dynamic RunHandler(Zone self, ZoneDelegate parent, Zone zone, f());
13 typedef dynamic RunUnaryHandler( 14 typedef dynamic RunUnaryHandler(
14 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg); 15 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg);
16 typedef dynamic RunBinaryHandler(
17 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2), arg1, arg2);
15 typedef ZoneCallback RegisterCallbackHandler( 18 typedef ZoneCallback RegisterCallbackHandler(
16 Zone self, ZoneDelegate parent, Zone zone, f()); 19 Zone self, ZoneDelegate parent, Zone zone, f());
17 typedef ZoneUnaryCallback RegisterUnaryCallbackHandler( 20 typedef ZoneUnaryCallback RegisterUnaryCallbackHandler(
18 Zone self, ZoneDelegate parent, Zone zone, f(arg)); 21 Zone self, ZoneDelegate parent, Zone zone, f(arg));
22 typedef ZoneBinaryCallback RegisterBinaryCallbackHandler(
23 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2));
19 typedef void ScheduleMicrotaskHandler( 24 typedef void ScheduleMicrotaskHandler(
20 Zone self, ZoneDelegate parent, Zone zone, f()); 25 Zone self, ZoneDelegate parent, Zone zone, f());
21 typedef Timer CreateTimerHandler( 26 typedef Timer CreateTimerHandler(
22 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()); 27 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f());
23 typedef Timer CreatePeriodicTimerHandler( 28 typedef Timer CreatePeriodicTimerHandler(
24 Zone self, ZoneDelegate parent, Zone zone, 29 Zone self, ZoneDelegate parent, Zone zone,
25 Duration period, void f(Timer timer)); 30 Duration period, void f(Timer timer));
26 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone, 31 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone,
27 ZoneSpecification specification, 32 ZoneSpecification specification,
28 Map<Symbol, dynamic> zoneValues); 33 Map<Symbol, dynamic> zoneValues);
(...skipping 15 matching lines...) Expand all
44 * 49 *
45 * Handlers can either stop propagation the request (by simply not calling the 50 * Handlers can either stop propagation the request (by simply not calling the
46 * parent handler), or forward to the parent zone, potentially modifying the 51 * parent handler), or forward to the parent zone, potentially modifying the
47 * arguments on the way. 52 * arguments on the way.
48 */ 53 */
49 abstract class ZoneSpecification { 54 abstract class ZoneSpecification {
50 /** 55 /**
51 * Creates a specification with the provided handlers. 56 * Creates a specification with the provided handlers.
52 */ 57 */
53 const factory ZoneSpecification({ 58 const factory ZoneSpecification({
54 void handleUncaughtError( 59 dynamic handleUncaughtError(Zone self, ZoneDelegate parent, Zone zone,
55 Zone self, ZoneDelegate parent, Zone zone, e): null, 60 error, StackTrace stackTrace): null,
56 dynamic run(Zone self, ZoneDelegate parent, Zone zone, f()): null, 61 dynamic run(Zone self, ZoneDelegate parent, Zone zone, f()): null,
57 dynamic runUnary( 62 dynamic runUnary(
58 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg): null, 63 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg): null,
64 dynamic runBinary(Zone self, ZoneDelegate parent, Zone zone,
65 f(arg1, arg2), arg1, arg2): null,
59 ZoneCallback registerCallback( 66 ZoneCallback registerCallback(
60 Zone self, ZoneDelegate parent, Zone zone, f()): null, 67 Zone self, ZoneDelegate parent, Zone zone, f()): null,
61 ZoneUnaryCallback registerUnaryCallback( 68 ZoneUnaryCallback registerUnaryCallback(
62 Zone self, ZoneDelegate parent, Zone zone, f(arg)): null, 69 Zone self, ZoneDelegate parent, Zone zone, f(arg)): null,
70 ZoneBinaryCallback registerBinaryCallback(
71 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null,
63 void scheduleMicrotask( 72 void scheduleMicrotask(
64 Zone self, ZoneDelegate parent, Zone zone, f()): null, 73 Zone self, ZoneDelegate parent, Zone zone, f()): null,
65 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, 74 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone,
66 Duration duration, void f()): null, 75 Duration duration, void f()): null,
67 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, 76 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone,
68 Duration period, void f(Timer timer)): null, 77 Duration period, void f(Timer timer)): null,
69 Zone fork(Zone self, ZoneDelegate parent, Zone zone, 78 Zone fork(Zone self, ZoneDelegate parent, Zone zone,
70 ZoneSpecification specification, Map zoneValues): null 79 ZoneSpecification specification, Map zoneValues): null
71 }) = _ZoneSpecification; 80 }) = _ZoneSpecification;
72 81
73 /** 82 /**
74 * Creates a specification from [other] with the provided handlers overriding 83 * Creates a specification from [other] with the provided handlers overriding
75 * the ones in [other]. 84 * the ones in [other].
76 */ 85 */
77 factory ZoneSpecification.from(ZoneSpecification other, { 86 factory ZoneSpecification.from(ZoneSpecification other, {
78 void handleUncaughtError( 87 dynamic handleUncaughtError(Zone self, ZoneDelegate parent, Zone zone,
79 Zone self, ZoneDelegate parent, Zone zone, e): null, 88 error, StackTrace stackTrace): null,
80 dynamic run(Zone self, ZoneDelegate parent, Zone zone, f()): null, 89 dynamic run(Zone self, ZoneDelegate parent, Zone zone, f()): null,
81 dynamic runUnary( 90 dynamic runUnary(
82 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg): null, 91 Zone self, ZoneDelegate parent, Zone zone, f(arg), arg): null,
92 dynamic runBinary(Zone self, ZoneDelegate parent, Zone zone,
93 f(arg1, arg2), arg1, arg2): null,
83 ZoneCallback registerCallback( 94 ZoneCallback registerCallback(
84 Zone self, ZoneDelegate parent, Zone zone, f()): null, 95 Zone self, ZoneDelegate parent, Zone zone, f()): null,
85 ZoneUnaryCallback registerUnaryCallback( 96 ZoneUnaryCallback registerUnaryCallback(
86 Zone self, ZoneDelegate parent, Zone zone, f(arg)): null, 97 Zone self, ZoneDelegate parent, Zone zone, f(arg)): null,
98 ZoneBinaryCallback registerBinaryCallback(
99 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null,
87 void scheduleMicrotask( 100 void scheduleMicrotask(
88 Zone self, ZoneDelegate parent, Zone zone, f()): null, 101 Zone self, ZoneDelegate parent, Zone zone, f()): null,
89 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, 102 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone,
90 Duration duration, void f()): null, 103 Duration duration, void f()): null,
91 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, 104 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone,
92 Duration period, void f(Timer timer)): null, 105 Duration period, void f(Timer timer)): null,
93 Zone fork(Zone self, ZoneDelegate parent, Zone zone, 106 Zone fork(Zone self, ZoneDelegate parent, Zone zone,
94 ZoneSpecification specification, 107 ZoneSpecification specification,
95 Map<Symbol, dynamic> zoneValues): null 108 Map<Symbol, dynamic> zoneValues): null
96 }) { 109 }) {
97 return new ZoneSpecification( 110 return new ZoneSpecification(
98 handleUncaughtError: handleUncaughtError != null 111 handleUncaughtError: handleUncaughtError != null
99 ? handleUncaughtError 112 ? handleUncaughtError
100 : other.handleUncaughtError, 113 : other.handleUncaughtError,
101 run: run != null ? run : other.run, 114 run: run != null ? run : other.run,
102 runUnary: runUnary != null ? runUnary : other.runUnary, 115 runUnary: runUnary != null ? runUnary : other.runUnary,
116 runBinary: runBinary != null ? runBinary : other.runBinary,
103 registerCallback: registerCallback != null 117 registerCallback: registerCallback != null
104 ? registerCallback 118 ? registerCallback
105 : other.registerCallback, 119 : other.registerCallback,
106 registerUnaryCallback: registerUnaryCallback != null 120 registerUnaryCallback: registerUnaryCallback != null
107 ? registerUnaryCallback 121 ? registerUnaryCallback
108 : other.registerUnaryCallback, 122 : other.registerUnaryCallback,
123 registerBinaryCallback: registerBinaryCallback != null
124 ? registerBinaryCallback
125 : other.registerBinaryCallback,
109 scheduleMicrotask: scheduleMicrotask != null 126 scheduleMicrotask: scheduleMicrotask != null
110 ? scheduleMicrotask 127 ? scheduleMicrotask
111 : other.scheduleMicrotask, 128 : other.scheduleMicrotask,
112 createTimer : createTimer != null ? createTimer : other.createTimer, 129 createTimer : createTimer != null ? createTimer : other.createTimer,
113 createPeriodicTimer: createPeriodicTimer != null 130 createPeriodicTimer: createPeriodicTimer != null
114 ? createPeriodicTimer 131 ? createPeriodicTimer
115 : other.createPeriodicTimer, 132 : other.createPeriodicTimer,
116 fork: fork != null ? fork : other.fork); 133 fork: fork != null ? fork : other.fork);
117 } 134 }
118 135
119 HandleUncaughtErrorHandler get handleUncaughtError; 136 HandleUncaughtErrorHandler get handleUncaughtError;
120 RunHandler get run; 137 RunHandler get run;
121 RunUnaryHandler get runUnary; 138 RunUnaryHandler get runUnary;
139 RunBinaryHandler get runBinary;
122 RegisterCallbackHandler get registerCallback; 140 RegisterCallbackHandler get registerCallback;
123 RegisterUnaryCallbackHandler get registerUnaryCallback; 141 RegisterUnaryCallbackHandler get registerUnaryCallback;
142 RegisterBinaryCallbackHandler get registerBinaryCallback;
124 ScheduleMicrotaskHandler get scheduleMicrotask; 143 ScheduleMicrotaskHandler get scheduleMicrotask;
125 CreateTimerHandler get createTimer; 144 CreateTimerHandler get createTimer;
126 CreatePeriodicTimerHandler get createPeriodicTimer; 145 CreatePeriodicTimerHandler get createPeriodicTimer;
127 ForkHandler get fork; 146 ForkHandler get fork;
128 } 147 }
129 148
130 /** 149 /**
131 * Internal [ZoneSpecification] class. 150 * Internal [ZoneSpecification] class.
132 * 151 *
133 * The implementation wants to rely on the fact that the getters cannot change 152 * The implementation wants to rely on the fact that the getters cannot change
134 * dynamically. We thus require users to go through the redirecting 153 * dynamically. We thus require users to go through the redirecting
135 * [ZoneSpecification] constructor which instantiates this class. 154 * [ZoneSpecification] constructor which instantiates this class.
136 */ 155 */
137 class _ZoneSpecification implements ZoneSpecification { 156 class _ZoneSpecification implements ZoneSpecification {
138 const _ZoneSpecification({ 157 const _ZoneSpecification({
139 this.handleUncaughtError: null, 158 this.handleUncaughtError: null,
140 this.run: null, 159 this.run: null,
141 this.runUnary: null, 160 this.runUnary: null,
161 this.runBinary: null,
142 this.registerCallback: null, 162 this.registerCallback: null,
143 this.registerUnaryCallback: null, 163 this.registerUnaryCallback: null,
164 this.registerBinaryCallback: null,
144 this.scheduleMicrotask: null, 165 this.scheduleMicrotask: null,
145 this.createTimer: null, 166 this.createTimer: null,
146 this.createPeriodicTimer: null, 167 this.createPeriodicTimer: null,
147 this.fork: null 168 this.fork: null
148 }); 169 });
149 170
150 // TODO(13406): Enable types when dart2js supports it. 171 // TODO(13406): Enable types when dart2js supports it.
151 final /*HandleUncaughtErrorHandler*/ handleUncaughtError; 172 final /*HandleUncaughtErrorHandler*/ handleUncaughtError;
152 final /*RunHandler*/ run; 173 final /*RunHandler*/ run;
153 final /*RunUnaryHandler*/ runUnary; 174 final /*RunUnaryHandler*/ runUnary;
175 final /*RunBinaryHandler*/ runBinary;
154 final /*RegisterCallbackHandler*/ registerCallback; 176 final /*RegisterCallbackHandler*/ registerCallback;
155 final /*RegisterUnaryCallbackHandler*/ registerUnaryCallback; 177 final /*RegisterUnaryCallbackHandler*/ registerUnaryCallback;
178 final /*RegisterBinaryCallbackHandler*/ registerBinaryCallback;
156 final /*ScheduleMicrotaskHandler*/ scheduleMicrotask; 179 final /*ScheduleMicrotaskHandler*/ scheduleMicrotask;
157 final /*CreateTimerHandler*/ createTimer; 180 final /*CreateTimerHandler*/ createTimer;
158 final /*CreatePeriodicTimerHandler*/ createPeriodicTimer; 181 final /*CreatePeriodicTimerHandler*/ createPeriodicTimer;
159 final /*ForkHandler*/ fork; 182 final /*ForkHandler*/ fork;
160 } 183 }
161 184
162 /** 185 /**
163 * This class wraps zones for delegation. 186 * This class wraps zones for delegation.
164 * 187 *
165 * When forwarding to parent zones one can't just invoke the parent zone's 188 * When forwarding to parent zones one can't just invoke the parent zone's
166 * exposed functions (like [Zone.run]), but one needs to provide more 189 * exposed functions (like [Zone.run]), but one needs to provide more
167 * information (like the zone the `run` was initiated). Zone callbacks thus 190 * information (like the zone the `run` was initiated). Zone callbacks thus
168 * receive more information including this [ZoneDelegate] class. When delegating 191 * receive more information including this [ZoneDelegate] class. When delegating
169 * to the parent zone one should go through the given instance instead of 192 * to the parent zone one should go through the given instance instead of
170 * directly invoking the parent zone. 193 * directly invoking the parent zone.
171 */ 194 */
172 abstract class ZoneDelegate { 195 abstract class ZoneDelegate {
173 /// The [Zone] this class wraps. 196 /// The [Zone] this class wraps.
174 Zone get _zone; 197 Zone get _zone;
175 198
176 dynamic handleUncaughtError(Zone zone, e); 199 dynamic handleUncaughtError(Zone zone, error, StackTrace stackTrace);
177 dynamic run(Zone zone, f()); 200 dynamic run(Zone zone, f());
178 dynamic runUnary(Zone zone, f(arg), arg); 201 dynamic runUnary(Zone zone, f(arg), arg);
202 dynamic runBinary(Zone zone, f(arg1, arg2), arg1, arg2);
179 ZoneCallback registerCallback(Zone zone, f()); 203 ZoneCallback registerCallback(Zone zone, f());
180 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg)); 204 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg));
205 ZoneBinaryCallback registerBinaryCallback(Zone zone, f(arg1, arg2));
181 void scheduleMicrotask(Zone zone, f()); 206 void scheduleMicrotask(Zone zone, f());
182 Timer createTimer(Zone zone, Duration duration, void f()); 207 Timer createTimer(Zone zone, Duration duration, void f());
183 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer)); 208 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer));
184 Zone fork(Zone zone, ZoneSpecification specification, Map zoneValues); 209 Zone fork(Zone zone, ZoneSpecification specification, Map zoneValues);
185 } 210 }
186 211
187 /** 212 /**
188 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous 213 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous
189 * callbacks are executed in the zone they have been queued in. For example, 214 * callbacks are executed in the zone they have been queued in. For example,
190 * the callback of a `future.then` is executed in the same zone as the one where 215 * the callback of a `future.then` is executed in the same zone as the one where
191 * the `then` was invoked. 216 * the `then` was invoked.
192 */ 217 */
193 abstract class Zone { 218 abstract class Zone {
194 // Private constructor so that it is not possible instantiate a Zone class. 219 // Private constructor so that it is not possible instantiate a Zone class.
195 Zone._(); 220 Zone._();
196 221
197 /// The root zone that is implicitly created. 222 /// The root zone that is implicitly created.
198 static const Zone ROOT = _ROOT_ZONE; 223 static const Zone ROOT = _ROOT_ZONE;
199 224
200 /// The currently running zone. 225 /// The currently running zone.
201 static Zone _current = _ROOT_ZONE; 226 static Zone _current = _ROOT_ZONE;
202 227
203 static Zone get current => _current; 228 static Zone get current => _current;
204 229
205 dynamic handleUncaughtError(error); 230 dynamic handleUncaughtError(error, StackTrace stackTrace);
206 231
207 /** 232 /**
208 * Returns the parent zone. 233 * Returns the parent zone.
209 * 234 *
210 * Returns `null` if `this` is the [ROOT] zone. 235 * Returns `null` if `this` is the [ROOT] zone.
211 */ 236 */
212 Zone get parent; 237 Zone get parent;
213 238
214 /** 239 /**
215 * Returns true if `this` and [otherZone] are in the same error zone. 240 * Returns true if `this` and [otherZone] are in the same error zone.
(...skipping 13 matching lines...) Expand all
229 * Executes the given function [f] in this zone. 254 * Executes the given function [f] in this zone.
230 */ 255 */
231 dynamic run(f()); 256 dynamic run(f());
232 257
233 /** 258 /**
234 * Executes the given callback [f] with argument [arg] in this zone. 259 * Executes the given callback [f] with argument [arg] in this zone.
235 */ 260 */
236 dynamic runUnary(f(arg), var arg); 261 dynamic runUnary(f(arg), var arg);
237 262
238 /** 263 /**
264 * Executes the given callback [f] with argument [arg1] and [arg2] in this
265 * zone.
266 */
267 dynamic runBinary(f(arg1, arg2), var arg1, var arg2);
268
269 /**
239 * Executes the given function [f] in this zone. 270 * Executes the given function [f] in this zone.
240 * 271 *
241 * Same as [run] but catches uncaught errors and gives them to 272 * Same as [run] but catches uncaught errors and gives them to
242 * [handleUncaughtError]. 273 * [handleUncaughtError].
243 */ 274 */
244 dynamic runGuarded(f()); 275 dynamic runGuarded(f());
245 276
246 /** 277 /**
247 * Executes the given callback [f] in this zone. 278 * Executes the given callback [f] in this zone.
248 * 279 *
249 * Same as [runUnary] but catches uncaught errors and gives them to 280 * Same as [runUnary] but catches uncaught errors and gives them to
250 * [handleUncaughtError]. 281 * [handleUncaughtError].
251 */ 282 */
252 dynamic runUnaryGuarded(f(arg), var arg); 283 dynamic runUnaryGuarded(f(arg), var arg);
253 284
254 /** 285 /**
286 * Executes the given callback [f] in this zone.
287 *
288 * Same as [runBinary] but catches uncaught errors and gives them to
289 * [handleUncaughtError].
290 */
291 dynamic runBinaryGuarded(f(arg1, arg2), var arg1, var arg2);
292
293 /**
255 * Registers the given callback in this zone. 294 * Registers the given callback in this zone.
256 * 295 *
257 * It is good practice to register asynchronous or delayed callbacks before 296 * It is good practice to register asynchronous or delayed callbacks before
258 * invoking [run]. This gives the zone a chance to wrap the callback and 297 * invoking [run]. This gives the zone a chance to wrap the callback and
259 * to store information with the callback. For example, a zone may decide 298 * to store information with the callback. For example, a zone may decide
260 * to store the stack trace (at the time of the registration) with the 299 * to store the stack trace (at the time of the registration) with the
261 * callback. 300 * callback.
262 * 301 *
263 * Returns a potentially new callback that should be used in place of the 302 * Returns a potentially new callback that should be used in place of the
264 * given [callback]. 303 * given [callback].
265 */ 304 */
266 ZoneCallback registerCallback(callback()); 305 ZoneCallback registerCallback(callback());
267 306
268 /** 307 /**
269 * Registers the given callback in this zone. 308 * Registers the given callback in this zone.
270 * 309 *
271 * Similar to [registerCallback] but with a unary callback. 310 * Similar to [registerCallback] but with a unary callback.
272 */ 311 */
273 ZoneUnaryCallback registerUnaryCallback(callback(arg)); 312 ZoneUnaryCallback registerUnaryCallback(callback(arg));
274 313
275 /** 314 /**
315 * Registers the given callback in this zone.
316 *
317 * Similar to [registerCallback] but with a unary callback.
318 */
319 ZoneBinaryCallback registerBinaryCallback(callback(arg1, arg2));
320
321 /**
276 * Equivalent to: 322 * Equivalent to:
277 * 323 *
278 * ZoneCallback registered = registerCallback(f); 324 * ZoneCallback registered = registerCallback(f);
279 * if (runGuarded) return () => this.runGuarded(registered); 325 * if (runGuarded) return () => this.runGuarded(registered);
280 * return () => this.run(registered); 326 * return () => this.run(registered);
281 * 327 *
282 */ 328 */
283 ZoneCallback bindCallback(f(), { bool runGuarded: true }); 329 ZoneCallback bindCallback(f(), { bool runGuarded: true });
330
284 /** 331 /**
285 * Equivalent to: 332 * Equivalent to:
286 * 333 *
287 * ZoneCallback registered = registerCallback1(f); 334 * ZoneCallback registered = registerUnaryCallback(f);
288 * if (runGuarded) return (arg) => this.runUnaryGuarded(registered, arg); 335 * if (runGuarded) return (arg) => this.runUnaryGuarded(registered, arg);
289 * return (arg) => thin.runUnary(registered, arg); 336 * return (arg) => thin.runUnary(registered, arg);
290 */ 337 */
291 ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true }); 338 ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true });
292 339
293 /** 340 /**
341 * Equivalent to:
342 *
343 * ZoneCallback registered = registerBinaryCallback(f);
344 * if (runGuarded) {
345 * return (arg1, arg2) => this.runBinaryGuarded(registered, arg);
346 * }
347 * return (arg1, arg2) => thin.runBinary(registered, arg1, arg2);
348 */
349 ZoneBinaryCallback bindBinaryCallback(
350 f(arg1, arg2), { bool runGuarded: true });
351
352 /**
294 * Runs [f] asynchronously. 353 * Runs [f] asynchronously.
295 */ 354 */
296 void scheduleMicrotask(void f()); 355 void scheduleMicrotask(void f());
297 356
298 /** 357 /**
299 * Creates a Timer where the callback is executed in this zone. 358 * Creates a Timer where the callback is executed in this zone.
300 */ 359 */
301 Timer createTimer(Duration duration, void callback()); 360 Timer createTimer(Duration duration, void callback());
302 361
303 /** 362 /**
(...skipping 16 matching lines...) Expand all
320 operator[](Symbol key); 379 operator[](Symbol key);
321 } 380 }
322 381
323 class _ZoneDelegate implements ZoneDelegate { 382 class _ZoneDelegate implements ZoneDelegate {
324 final _CustomizedZone _degelationTarget; 383 final _CustomizedZone _degelationTarget;
325 384
326 Zone get _zone => _degelationTarget; 385 Zone get _zone => _degelationTarget;
327 386
328 const _ZoneDelegate(this._degelationTarget); 387 const _ZoneDelegate(this._degelationTarget);
329 388
330 dynamic handleUncaughtError(Zone zone, e) { 389 dynamic handleUncaughtError(Zone zone, error, StackTrace stackTrace) {
331 _CustomizedZone parent = _degelationTarget; 390 _CustomizedZone parent = _degelationTarget;
332 while (parent._specification.handleUncaughtError == null) { 391 while (parent._specification.handleUncaughtError == null) {
333 parent = parent.parent; 392 parent = parent.parent;
334 } 393 }
335 return (parent._specification.handleUncaughtError)( 394 return (parent._specification.handleUncaughtError)(
336 parent, new _ZoneDelegate(parent.parent), zone, e); 395 parent, new _ZoneDelegate(parent.parent), zone, error, stackTrace);
337 } 396 }
338 397
339 dynamic run(Zone zone, f()) { 398 dynamic run(Zone zone, f()) {
340 _CustomizedZone parent = _degelationTarget; 399 _CustomizedZone parent = _degelationTarget;
341 while (parent._specification.run == null) { 400 while (parent._specification.run == null) {
342 parent = parent.parent; 401 parent = parent.parent;
343 } 402 }
344 return (parent._specification.run)( 403 return (parent._specification.run)(
345 parent, new _ZoneDelegate(parent.parent), zone, f); 404 parent, new _ZoneDelegate(parent.parent), zone, f);
346 } 405 }
347 406
348 dynamic runUnary(Zone zone, f(arg), arg) { 407 dynamic runUnary(Zone zone, f(arg), arg) {
349 _CustomizedZone parent = _degelationTarget; 408 _CustomizedZone parent = _degelationTarget;
350 while (parent._specification.runUnary == null) { 409 while (parent._specification.runUnary == null) {
351 parent = parent.parent; 410 parent = parent.parent;
352 } 411 }
353 return (parent._specification.runUnary)( 412 return (parent._specification.runUnary)(
354 parent, new _ZoneDelegate(parent.parent), zone, f, arg); 413 parent, new _ZoneDelegate(parent.parent), zone, f, arg);
355 } 414 }
356 415
416 dynamic runBinary(Zone zone, f(arg1, arg2), arg1, arg2) {
417 _CustomizedZone parent = _degelationTarget;
418 while (parent._specification.runBinary == null) {
419 parent = parent.parent;
420 }
421 return (parent._specification.runBinary)(
422 parent, new _ZoneDelegate(parent.parent), zone, f, arg1, arg2);
423 }
424
357 ZoneCallback registerCallback(Zone zone, f()) { 425 ZoneCallback registerCallback(Zone zone, f()) {
358 _CustomizedZone parent = _degelationTarget; 426 _CustomizedZone parent = _degelationTarget;
359 while (parent._specification.registerCallback == null) { 427 while (parent._specification.registerCallback == null) {
360 parent = parent.parent; 428 parent = parent.parent;
361 } 429 }
362 return (parent._specification.registerCallback)( 430 return (parent._specification.registerCallback)(
363 parent, new _ZoneDelegate(parent.parent), zone, f); 431 parent, new _ZoneDelegate(parent.parent), zone, f);
364 } 432 }
365 433
366 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg)) { 434 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg)) {
367 _CustomizedZone parent = _degelationTarget; 435 _CustomizedZone parent = _degelationTarget;
368 while (parent._specification.registerUnaryCallback == null) { 436 while (parent._specification.registerUnaryCallback == null) {
369 parent = parent.parent; 437 parent = parent.parent;
370 } 438 }
371 return (parent._specification.registerUnaryCallback)( 439 return (parent._specification.registerUnaryCallback)(
372 parent, new _ZoneDelegate(parent.parent), zone, f); 440 parent, new _ZoneDelegate(parent.parent), zone, f);
373 } 441 }
374 442
443 ZoneBinaryCallback registerBinaryCallback(Zone zone, f(arg1, arg2)) {
444 _CustomizedZone parent = _degelationTarget;
445 while (parent._specification.registerBinaryCallback == null) {
446 parent = parent.parent;
447 }
448 return (parent._specification.registerBinaryCallback)(
449 parent, new _ZoneDelegate(parent.parent), zone, f);
450 }
451
375 void scheduleMicrotask(Zone zone, f()) { 452 void scheduleMicrotask(Zone zone, f()) {
376 _CustomizedZone parent = _degelationTarget; 453 _CustomizedZone parent = _degelationTarget;
377 while (parent._specification.scheduleMicrotask == null) { 454 while (parent._specification.scheduleMicrotask == null) {
378 parent = parent.parent; 455 parent = parent.parent;
379 } 456 }
380 _ZoneDelegate grandParent = new _ZoneDelegate(parent.parent); 457 _ZoneDelegate grandParent = new _ZoneDelegate(parent.parent);
381 (parent._specification.scheduleMicrotask)(parent, grandParent, zone, f); 458 (parent._specification.scheduleMicrotask)(parent, grandParent, zone, f);
382 } 459 }
383 460
384 Timer createTimer(Zone zone, Duration duration, void f()) { 461 Timer createTimer(Zone zone, Duration duration, void f()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if (_specification.handleUncaughtError != null) return this; 506 if (_specification.handleUncaughtError != null) return this;
430 return parent._errorZone; 507 return parent._errorZone;
431 } 508 }
432 509
433 bool inSameErrorZone(Zone otherZone) => _errorZone == otherZone._errorZone; 510 bool inSameErrorZone(Zone otherZone) => _errorZone == otherZone._errorZone;
434 511
435 dynamic runGuarded(f()) { 512 dynamic runGuarded(f()) {
436 try { 513 try {
437 return run(f); 514 return run(f);
438 } catch (e, s) { 515 } catch (e, s) {
439 return handleUncaughtError(_asyncError(e, s)); 516 return handleUncaughtError(e, s);
440 } 517 }
441 } 518 }
442 519
443 dynamic runUnaryGuarded(f(arg), arg) { 520 dynamic runUnaryGuarded(f(arg), arg) {
444 try { 521 try {
445 return runUnary(f, arg); 522 return runUnary(f, arg);
446 } catch (e, s) { 523 } catch (e, s) {
447 return handleUncaughtError(_asyncError(e, s)); 524 return handleUncaughtError(e, s);
448 } 525 }
449 } 526 }
450 527
528 dynamic runBinaryGuarded(f(arg1, arg2), arg1, arg2) {
529 try {
530 return runBinary(f, arg1, arg2);
531 } catch (e, s) {
532 return handleUncaughtError(e, s);
533 }
534 }
535
451 ZoneCallback bindCallback(f(), { bool runGuarded: true }) { 536 ZoneCallback bindCallback(f(), { bool runGuarded: true }) {
452 ZoneCallback registered = registerCallback(f); 537 ZoneCallback registered = registerCallback(f);
453 if (runGuarded) { 538 if (runGuarded) {
454 return () => this.runGuarded(registered); 539 return () => this.runGuarded(registered);
455 } else { 540 } else {
456 return () => this.run(registered); 541 return () => this.run(registered);
457 } 542 }
458 } 543 }
459 544
460 ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true }) { 545 ZoneUnaryCallback bindUnaryCallback(f(arg), { bool runGuarded: true }) {
461 ZoneUnaryCallback registered = registerUnaryCallback(f); 546 ZoneUnaryCallback registered = registerUnaryCallback(f);
462 if (runGuarded) { 547 if (runGuarded) {
463 return (arg) => this.runUnaryGuarded(registered, arg); 548 return (arg) => this.runUnaryGuarded(registered, arg);
464 } else { 549 } else {
465 return (arg) => this.runUnary(registered, arg); 550 return (arg) => this.runUnary(registered, arg);
466 } 551 }
467 } 552 }
468 553
554 ZoneBinaryCallback bindBinaryCallback(
555 f(arg1, arg2), { bool runGuarded: true }) {
556 ZoneBinaryCallback registered = registerBinaryCallback(f);
557 if (runGuarded) {
558 return (arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2);
559 } else {
560 return (arg1, arg2) => this.runBinary(registered, arg1, arg2);
561 }
562 }
563
469 operator [](Symbol key) { 564 operator [](Symbol key) {
470 var result = _map[key]; 565 var result = _map[key];
471 if (result != null || _map.containsKey(key)) return result; 566 if (result != null || _map.containsKey(key)) return result;
472 // If we are not the root zone look up in the parent zone. 567 // If we are not the root zone look up in the parent zone.
473 if (parent != null) return parent[key]; 568 if (parent != null) return parent[key];
474 assert(this == Zone.ROOT); 569 assert(this == Zone.ROOT);
475 return null; 570 return null;
476 } 571 }
477 572
478 // Methods that can be customized by the zone specification. 573 // Methods that can be customized by the zone specification.
479 574
480 dynamic handleUncaughtError(error) { 575 dynamic handleUncaughtError(error, StackTrace stackTrace) {
481 return new _ZoneDelegate(this).handleUncaughtError(this, error); 576 return new _ZoneDelegate(this).handleUncaughtError(this, error, stackTrace);
482 } 577 }
483 578
484 Zone fork({ZoneSpecification specification, Map zoneValues}) { 579 Zone fork({ZoneSpecification specification, Map zoneValues}) {
485 return new _ZoneDelegate(this).fork(this, specification, zoneValues); 580 return new _ZoneDelegate(this).fork(this, specification, zoneValues);
486 } 581 }
487 582
488 dynamic run(f()) { 583 dynamic run(f()) {
489 return new _ZoneDelegate(this).run(this, f); 584 return new _ZoneDelegate(this).run(this, f);
490 } 585 }
491 586
492 dynamic runUnary(f(arg), arg) { 587 dynamic runUnary(f(arg), arg) {
493 return new _ZoneDelegate(this).runUnary(this, f, arg); 588 return new _ZoneDelegate(this).runUnary(this, f, arg);
494 } 589 }
495 590
591 dynamic runBinary(f(arg1, arg2), arg1, arg2) {
592 return new _ZoneDelegate(this).runBinary(this, f, arg1, arg2);
593 }
594
496 ZoneCallback registerCallback(f()) { 595 ZoneCallback registerCallback(f()) {
497 return new _ZoneDelegate(this).registerCallback(this, f); 596 return new _ZoneDelegate(this).registerCallback(this, f);
498 } 597 }
499 598
500 ZoneUnaryCallback registerUnaryCallback(f(arg)) { 599 ZoneUnaryCallback registerUnaryCallback(f(arg)) {
501 return new _ZoneDelegate(this).registerUnaryCallback(this, f); 600 return new _ZoneDelegate(this).registerUnaryCallback(this, f);
502 } 601 }
503 602
603 ZoneBinaryCallback registerBinaryCallback(f(arg1, arg2)) {
604 return new _ZoneDelegate(this).registerBinaryCallback(this, f);
605 }
606
504 void scheduleMicrotask(void f()) { 607 void scheduleMicrotask(void f()) {
505 new _ZoneDelegate(this).scheduleMicrotask(this, f); 608 new _ZoneDelegate(this).scheduleMicrotask(this, f);
506 } 609 }
507 610
508 Timer createTimer(Duration duration, void f()) { 611 Timer createTimer(Duration duration, void f()) {
509 return new _ZoneDelegate(this).createTimer(this, duration, f); 612 return new _ZoneDelegate(this).createTimer(this, duration, f);
510 } 613 }
511 614
512 Timer createPeriodicTimer(Duration duration, void f(Timer timer)) { 615 Timer createPeriodicTimer(Duration duration, void f(Timer timer)) {
513 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f); 616 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f);
514 } 617 }
515 } 618 }
516 619
517 void _rootHandleUncaughtError( 620 void _rootHandleUncaughtError(
518 Zone self, ZoneDelegate parent, Zone zone, error) { 621 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) {
519 _scheduleAsyncCallback(() { 622 _scheduleAsyncCallback(() {
520 print("Uncaught Error: ${error}"); 623 print("Uncaught Error: ${error}");
521 var trace = getAttachedStackTrace(error); 624 var trace = stackTrace;
625 if (trace == null) trace = getAttachedStackTrace(error);
626 // Clear the attached stack trace (if any).
522 _attachStackTrace(error, null); 627 _attachStackTrace(error, null);
523 if (trace != null) { 628 if (trace != null) {
524 print("Stack Trace:\n$trace\n"); 629 print("Stack Trace: \n$trace\n");
525 } 630 }
526 throw error; 631 throw error;
527 }); 632 });
528 } 633 }
529 634
530 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) { 635 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) {
531 if (Zone._current == zone) return f(); 636 if (Zone._current == zone) return f();
532 637
533 Zone old = Zone._current; 638 Zone old = Zone._current;
534 try { 639 try {
535 Zone._current = zone; 640 Zone._current = zone;
536 return f(); 641 return f();
537 } finally { 642 } finally {
538 Zone._current = old; 643 Zone._current = old;
539 } 644 }
540 } 645 }
541 646
542 dynamic _rootRunUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) { 647 dynamic _rootRunUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) {
543 if (Zone._current == zone) return f(arg); 648 if (Zone._current == zone) return f(arg);
544 649
545 Zone old = Zone._current; 650 Zone old = Zone._current;
546 try { 651 try {
547 Zone._current = zone; 652 Zone._current = zone;
548 return f(arg); 653 return f(arg);
549 } finally { 654 } finally {
550 Zone._current = old; 655 Zone._current = old;
551 } 656 }
552 } 657 }
553 658
659 dynamic _rootRunBinary(Zone self, ZoneDelegate parent, Zone zone,
660 f(arg1, arg2), arg1, arg2) {
661 if (Zone._current == zone) return f(arg1, arg2);
662
663 Zone old = Zone._current;
664 try {
665 Zone._current = zone;
666 return f(arg1, arg2);
667 } finally {
668 Zone._current = old;
669 }
670 }
671
554 ZoneCallback _rootRegisterCallback( 672 ZoneCallback _rootRegisterCallback(
555 Zone self, ZoneDelegate parent, Zone zone, f()) { 673 Zone self, ZoneDelegate parent, Zone zone, f()) {
556 return f; 674 return f;
557 } 675 }
558 676
559 ZoneUnaryCallback _rootRegisterUnaryCallback( 677 ZoneUnaryCallback _rootRegisterUnaryCallback(
560 Zone self, ZoneDelegate parent, Zone zone, f(arg)) { 678 Zone self, ZoneDelegate parent, Zone zone, f(arg)) {
561 return f; 679 return f;
562 } 680 }
563 681
682 ZoneBinaryCallback _rootRegisterBinaryCallback(
683 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)) {
684 return f;
685 }
686
564 void _rootScheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, f()) { 687 void _rootScheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, f()) {
565 _scheduleAsyncCallback(f); 688 _scheduleAsyncCallback(f);
566 } 689 }
567 690
568 Timer _rootCreateTimer(Zone self, ZoneDelegate parent, Zone zone, 691 Timer _rootCreateTimer(Zone self, ZoneDelegate parent, Zone zone,
569 Duration duration, void callback()) { 692 Duration duration, void callback()) {
570 return _createTimer(duration, callback); 693 return _createTimer(duration, callback);
571 } 694 }
572 695
573 Timer _rootCreatePeriodicTimer( 696 Timer _rootCreatePeriodicTimer(
(...skipping 20 matching lines...) Expand all
594 copiedMap[key] = value; 717 copiedMap[key] = value;
595 }); 718 });
596 } 719 }
597 return new _CustomizedZone(zone, specification, copiedMap); 720 return new _CustomizedZone(zone, specification, copiedMap);
598 } 721 }
599 722
600 const _ROOT_SPECIFICATION = const ZoneSpecification( 723 const _ROOT_SPECIFICATION = const ZoneSpecification(
601 handleUncaughtError: _rootHandleUncaughtError, 724 handleUncaughtError: _rootHandleUncaughtError,
602 run: _rootRun, 725 run: _rootRun,
603 runUnary: _rootRunUnary, 726 runUnary: _rootRunUnary,
727 runBinary: _rootRunBinary,
604 registerCallback: _rootRegisterCallback, 728 registerCallback: _rootRegisterCallback,
605 registerUnaryCallback: _rootRegisterUnaryCallback, 729 registerUnaryCallback: _rootRegisterUnaryCallback,
730 registerBinaryCallback: _rootRegisterBinaryCallback,
606 scheduleMicrotask: _rootScheduleMicrotask, 731 scheduleMicrotask: _rootScheduleMicrotask,
607 createTimer: _rootCreateTimer, 732 createTimer: _rootCreateTimer,
608 createPeriodicTimer: _rootCreatePeriodicTimer, 733 createPeriodicTimer: _rootCreatePeriodicTimer,
609 fork: _rootFork 734 fork: _rootFork
610 ); 735 );
611 736
612 const _ROOT_ZONE = 737 const _ROOT_ZONE =
613 const _CustomizedZone(null, _ROOT_SPECIFICATION, const <Symbol, dynamic>{}); 738 const _CustomizedZone(null, _ROOT_SPECIFICATION, const <Symbol, dynamic>{});
614 739
615 740
(...skipping 18 matching lines...) Expand all
634 * 759 *
635 * Example: 760 * Example:
636 * 761 *
637 * runZonedExperimental(() { 762 * runZonedExperimental(() {
638 * new Future(() { throw "asynchronous error"; }); 763 * new Future(() { throw "asynchronous error"; });
639 * }, onError: print); // Will print "asynchronous error". 764 * }, onError: print); // Will print "asynchronous error".
640 */ 765 */
641 dynamic runZoned(body(), 766 dynamic runZoned(body(),
642 { Map<Symbol, dynamic> zoneValues, 767 { Map<Symbol, dynamic> zoneValues,
643 ZoneSpecification zoneSpecification, 768 ZoneSpecification zoneSpecification,
644 void onError(error) }) { 769 Function onError }) {
645 HandleUncaughtErrorHandler errorHandler; 770 HandleUncaughtErrorHandler errorHandler;
646 if (onError != null) { 771 if (onError != null) {
647 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error) { 772 errorHandler = (Zone self, ZoneDelegate parent, Zone zone,
773 error, StackTrace stackTrace) {
648 try { 774 try {
775 if (onError is ZoneBinaryCallback) {
776 return self.parent.runBinary(onError, error, stackTrace);
777 }
649 return self.parent.runUnary(onError, error); 778 return self.parent.runUnary(onError, error);
650 } catch(e, s) { 779 } catch(e, s) {
651 if (identical(e, error)) { 780 if (identical(e, error)) {
652 return parent.handleUncaughtError(zone, error); 781 return parent.handleUncaughtError(zone, error, stackTrace);
653 } else { 782 } else {
654 return parent.handleUncaughtError(zone, _asyncError(e, s)); 783 return parent.handleUncaughtError(zone, e, s);
655 } 784 }
656 } 785 }
657 }; 786 };
658 } 787 }
659 if (zoneSpecification == null) { 788 if (zoneSpecification == null) {
660 zoneSpecification = 789 zoneSpecification =
661 new ZoneSpecification(handleUncaughtError: errorHandler); 790 new ZoneSpecification(handleUncaughtError: errorHandler);
662 } else if (errorHandler != null) { 791 } else if (errorHandler != null) {
663 zoneSpecification = 792 zoneSpecification =
664 new ZoneSpecification.from(zoneSpecification, 793 new ZoneSpecification.from(zoneSpecification,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 @deprecated 826 @deprecated
698 runZonedExperimental(body(), 827 runZonedExperimental(body(),
699 { void onRunAsync(void callback()), 828 { void onRunAsync(void callback()),
700 void onError(error), 829 void onError(error),
701 void onDone() }) { 830 void onDone() }) {
702 if (onRunAsync == null) { 831 if (onRunAsync == null) {
703 return runZoned(body, onError: onError); 832 return runZoned(body, onError: onError);
704 } 833 }
705 HandleUncaughtErrorHandler errorHandler; 834 HandleUncaughtErrorHandler errorHandler;
706 if (onError != null) { 835 if (onError != null) {
707 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error) { 836 errorHandler = (Zone self, ZoneDelegate parent, Zone zone,
837 error, StackTrace stackTrace) {
708 try { 838 try {
709 return self.parent.runUnary(onError, error); 839 return self.parent.runUnary(onError, error);
710 } catch(e, s) { 840 } catch(e, s) {
711 if (identical(e, error)) { 841 if (identical(e, error)) {
712 return parent.handleUncaughtError(zone, error); 842 return parent.handleUncaughtError(zone, error, stackTrace);
713 } else { 843 } else {
714 return parent.handleUncaughtError(zone, _asyncError(e, s)); 844 return parent.handleUncaughtError(zone, _asyncError(e, s), s);
715 } 845 }
716 } 846 }
717 }; 847 };
718 } 848 }
719 ScheduleMicrotaskHandler asyncHandler; 849 ScheduleMicrotaskHandler asyncHandler;
720 if (onRunAsync != null) { 850 if (onRunAsync != null) {
721 asyncHandler = (Zone self, ZoneDelegate parent, Zone zone, f()) { 851 asyncHandler = (Zone self, ZoneDelegate parent, Zone zone, f()) {
722 self.parent.runUnary(onRunAsync, () => zone.runGuarded(f)); 852 self.parent.runUnary(onRunAsync, () => zone.runGuarded(f));
723 }; 853 };
724 } 854 }
725 ZoneSpecification specification = 855 ZoneSpecification specification =
726 new ZoneSpecification(handleUncaughtError: errorHandler, 856 new ZoneSpecification(handleUncaughtError: errorHandler,
727 scheduleMicrotask: asyncHandler); 857 scheduleMicrotask: asyncHandler);
728 Zone zone = Zone.current.fork(specification: specification); 858 Zone zone = Zone.current.fork(specification: specification);
729 if (onError != null) { 859 if (onError != null) {
730 return zone.runGuarded(body); 860 return zone.runGuarded(body);
731 } else { 861 } else {
732 return zone.run(body); 862 return zone.run(body);
733 } 863 }
734 } 864 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | tests/lib/async/catch_errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698