| Index: sdk/lib/async/zone.dart
|
| diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
|
| index 80184c2e75e67f00ef01e7c42e0f269589dbd582..cec32f697a28c725e7d6eecd3189fb1dbf4aedd0 100644
|
| --- a/sdk/lib/async/zone.dart
|
| +++ b/sdk/lib/async/zone.dart
|
| @@ -521,22 +521,22 @@ class _ZoneDelegate implements ZoneDelegate {
|
|
|
|
|
| /**
|
| - * Default implementation of a [Zone].
|
| + * Base class for Zone implementations.
|
| */
|
| -class _CustomizedZone implements Zone {
|
| +abstract class _BaseZone implements Zone {
|
| + const _BaseZone();
|
| +
|
| /// The parent zone.
|
| - final _CustomizedZone parent;
|
| + _BaseZone get parent;
|
| /// The zone's handlers.
|
| - final ZoneSpecification _specification;
|
| - /// The zone's value map.
|
| - final Map<Symbol, dynamic> _map;
|
| -
|
| - const _CustomizedZone(this.parent, this._specification, this._map);
|
| -
|
| - Zone get _errorZone {
|
| - if (_specification.handleUncaughtError != null) return this;
|
| - return parent._errorZone;
|
| - }
|
| + ZoneSpecification get _specification;
|
| + /**
|
| + * The closest error-handling zone.
|
| + *
|
| + * Returns `this` if `this` has an error-handler. Otherwise returns the
|
| + * parent's error-zone.
|
| + */
|
| + Zone get _errorZone;
|
|
|
| bool inSameErrorZone(Zone otherZone) => _errorZone == otherZone._errorZone;
|
|
|
| @@ -591,6 +591,25 @@ class _CustomizedZone implements Zone {
|
| return (arg1, arg2) => this.runBinary(registered, arg1, arg2);
|
| }
|
| }
|
| +}
|
| +
|
| +
|
| +/**
|
| + * Default implementation of a [Zone].
|
| + */
|
| +class _CustomizedZone extends _BaseZone {
|
| + final _BaseZone parent;
|
| + final ZoneSpecification _specification;
|
| +
|
| + /// The zone's value map.
|
| + final Map<Symbol, dynamic> _map;
|
| +
|
| + const _CustomizedZone(this.parent, this._specification, this._map);
|
| +
|
| + Zone get _errorZone {
|
| + if (_specification.handleUncaughtError != null) return this;
|
| + return parent._errorZone;
|
| + }
|
|
|
| operator [](Symbol key) {
|
| var result = _map[key];
|
| @@ -756,22 +775,80 @@ Zone _rootFork(Zone self, ZoneDelegate parent, Zone zone,
|
| return new _CustomizedZone(zone, specification, copiedMap);
|
| }
|
|
|
| -const _ROOT_SPECIFICATION = const ZoneSpecification(
|
| - handleUncaughtError: _rootHandleUncaughtError,
|
| - run: _rootRun,
|
| - runUnary: _rootRunUnary,
|
| - runBinary: _rootRunBinary,
|
| - registerCallback: _rootRegisterCallback,
|
| - registerUnaryCallback: _rootRegisterUnaryCallback,
|
| - registerBinaryCallback: _rootRegisterBinaryCallback,
|
| - scheduleMicrotask: _rootScheduleMicrotask,
|
| - createTimer: _rootCreateTimer,
|
| - createPeriodicTimer: _rootCreatePeriodicTimer,
|
| - fork: _rootFork
|
| -);
|
| -
|
| -const _ROOT_ZONE =
|
| - const _CustomizedZone(null, _ROOT_SPECIFICATION, const <Symbol, dynamic>{});
|
| +class _RootZoneSpecification implements ZoneSpecification {
|
| + const _RootZoneSpecification();
|
| +
|
| + HandleUncaughtErrorHandler get handleUncaughtError =>
|
| + _rootHandleUncaughtError;
|
| + RunHandler get run => _rootRun;
|
| + RunUnaryHandler get runUnary => _rootRunUnary;
|
| + RunBinaryHandler get runBinary => _rootRunBinary;
|
| + RegisterCallbackHandler get registerCallback => _rootRegisterCallback;
|
| + RegisterUnaryCallbackHandler get registerUnaryCallback =>
|
| + _rootRegisterUnaryCallback;
|
| + RegisterBinaryCallbackHandler get registerBinaryCallback =>
|
| + _rootRegisterBinaryCallback;
|
| + ScheduleMicrotaskHandler get scheduleMicrotask => _rootScheduleMicrotask;
|
| + @deprecated
|
| + RunAsyncHandler get runAsync => null;
|
| + CreateTimerHandler get createTimer => _rootCreateTimer;
|
| + CreatePeriodicTimerHandler get createPeriodicTimer =>
|
| + _rootCreatePeriodicTimer;
|
| + ForkHandler get fork => _rootFork;
|
| +}
|
| +
|
| +class _RootZone extends _BaseZone {
|
| + const _RootZone();
|
| +
|
| + Zone get parent => null;
|
| + ZoneSpecification get _specification => const _RootZoneSpecification();
|
| + Zone get _errorZone => this;
|
| +
|
| + bool inSameErrorZone(Zone otherZone) => otherZone._errorZone == this;
|
| +
|
| + operator [](Symbol key) => null;
|
| +
|
| + // Methods that can be customized by the zone specification.
|
| +
|
| + dynamic handleUncaughtError(error, StackTrace stackTrace) =>
|
| + _rootHandleUncaughtError(this, null, this, error, stackTrace);
|
| +
|
| + Zone fork({ZoneSpecification specification, Map zoneValues}) =>
|
| + _rootFork(this, null, this, specification, zoneValues);
|
| +
|
| + dynamic run(f()) => _rootRun(this, null, this, f);
|
| +
|
| + dynamic runUnary(f(arg), arg) => _rootRunUnary(this, null, this, f, arg);
|
| +
|
| + dynamic runBinary(f(arg1, arg2), arg1, arg2) =>
|
| + _rootRunBinary(this, null, this, f, arg1, arg2);
|
| +
|
| + ZoneCallback registerCallback(f()) =>
|
| + _rootRegisterCallback(this, null, this, f);
|
| +
|
| + ZoneUnaryCallback registerUnaryCallback(f(arg)) =>
|
| + _rootRegisterUnaryCallback(this, null, this, f);
|
| +
|
| + ZoneBinaryCallback registerBinaryCallback(f(arg1, arg2)) =>
|
| + _rootRegisterBinaryCallback(this, null, this, f);
|
| +
|
| + void scheduleMicrotask(void f()) {
|
| + _rootScheduleMicrotask(this, null, this, f);
|
| + }
|
| +
|
| + @deprecated
|
| + void runAsync(void f()) {
|
| + scheduleMicrotask(f);
|
| + }
|
| +
|
| + Timer createTimer(Duration duration, void f()) =>
|
| + _rootCreateTimer(this, null, this, duration, f);
|
| +
|
| + Timer createPeriodicTimer(Duration duration, void f(Timer timer)) =>
|
| + _rootCreatePeriodicTimer(this, null, this, duration, f);
|
| +}
|
| +
|
| +const _ROOT_ZONE = const _RootZone();
|
|
|
|
|
| /**
|
|
|