| OLD | NEW |
| 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 typedef dynamic ZoneBinaryCallback(arg1, arg2); |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()); | 29 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()); |
| 30 typedef Timer CreatePeriodicTimerHandler( | 30 typedef Timer CreatePeriodicTimerHandler( |
| 31 Zone self, ZoneDelegate parent, Zone zone, | 31 Zone self, ZoneDelegate parent, Zone zone, |
| 32 Duration period, void f(Timer timer)); | 32 Duration period, void f(Timer timer)); |
| 33 typedef void PrintHandler( | 33 typedef void PrintHandler( |
| 34 Zone self, ZoneDelegate parent, Zone zone, String line); | 34 Zone self, ZoneDelegate parent, Zone zone, String line); |
| 35 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone, | 35 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone, |
| 36 ZoneSpecification specification, | 36 ZoneSpecification specification, |
| 37 Map zoneValues); | 37 Map zoneValues); |
| 38 | 38 |
| 39 /// Pair of error and stack trace. Returned by [Zone.errorCallback]. | 39 /** Pair of error and stack trace. Returned by [Zone.errorCallback]. */ |
| 40 class AsyncError implements Error { | 40 class AsyncError implements Error { |
| 41 final error; | 41 final error; |
| 42 final StackTrace stackTrace; | 42 final StackTrace stackTrace; |
| 43 | 43 |
| 44 AsyncError(this.error, this.stackTrace); | 44 AsyncError(this.error, this.stackTrace); |
| 45 |
| 45 String toString() => error.toString(); | 46 String toString() => error.toString(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 | 49 |
| 49 class _ZoneFunction { | 50 class _ZoneFunction { |
| 50 final _Zone zone; | 51 final _Zone zone; |
| 51 final Function function; | 52 final Function function; |
| 52 const _ZoneFunction(this.zone, this.function); | 53 const _ZoneFunction(this.zone, this.function); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 /** | 248 /** |
| 248 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous | 249 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous |
| 249 * callbacks are executed in the zone they have been queued in. For example, | 250 * callbacks are executed in the zone they have been queued in. For example, |
| 250 * the callback of a `future.then` is executed in the same zone as the one where | 251 * the callback of a `future.then` is executed in the same zone as the one where |
| 251 * the `then` was invoked. | 252 * the `then` was invoked. |
| 252 */ | 253 */ |
| 253 abstract class Zone { | 254 abstract class Zone { |
| 254 // Private constructor so that it is not possible instantiate a Zone class. | 255 // Private constructor so that it is not possible instantiate a Zone class. |
| 255 Zone._(); | 256 Zone._(); |
| 256 | 257 |
| 257 /// The root zone that is implicitly created. | 258 /** The root zone that is implicitly created. */ |
| 258 static const Zone ROOT = _ROOT_ZONE; | 259 static const Zone ROOT = _ROOT_ZONE; |
| 259 | 260 |
| 260 /// The currently running zone. | 261 /** The currently running zone. */ |
| 261 static Zone _current = _ROOT_ZONE; | 262 static Zone _current = _ROOT_ZONE; |
| 262 | 263 |
| 263 static Zone get current => _current; | 264 static Zone get current => _current; |
| 264 | 265 |
| 265 dynamic handleUncaughtError(error, StackTrace stackTrace); | 266 dynamic handleUncaughtError(error, StackTrace stackTrace); |
| 266 | 267 |
| 267 /** | 268 /** |
| 268 * Returns the parent zone. | 269 * Returns the parent zone. |
| 269 * | 270 * |
| 270 * Returns `null` if `this` is the [ROOT] zone. | 271 * Returns `null` if `this` is the [ROOT] zone. |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 handleUncaughtError: errorHandler); | 1241 handleUncaughtError: errorHandler); |
| 1241 } | 1242 } |
| 1242 Zone zone = Zone.current.fork(specification: zoneSpecification, | 1243 Zone zone = Zone.current.fork(specification: zoneSpecification, |
| 1243 zoneValues: zoneValues); | 1244 zoneValues: zoneValues); |
| 1244 if (onError != null) { | 1245 if (onError != null) { |
| 1245 return zone.runGuarded(body); | 1246 return zone.runGuarded(body); |
| 1246 } else { | 1247 } else { |
| 1247 return zone.run(body); | 1248 return zone.run(body); |
| 1248 } | 1249 } |
| 1249 } | 1250 } |
| OLD | NEW |