| Index: sdk/lib/async/zone.dart
|
| diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
|
| index 80184c2e75e67f00ef01e7c42e0f269589dbd582..22987ddd60f3f615844bcedd127110a52229b4b4 100644
|
| --- a/sdk/lib/async/zone.dart
|
| +++ b/sdk/lib/async/zone.dart
|
| @@ -31,6 +31,8 @@ typedef Timer CreateTimerHandler(
|
| typedef Timer CreatePeriodicTimerHandler(
|
| Zone self, ZoneDelegate parent, Zone zone,
|
| Duration period, void f(Timer timer));
|
| +typedef void PrintHandler(
|
| + Zone self, ZoneDelegate parent, Zone zone, String line);
|
| typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone,
|
| ZoneSpecification specification,
|
| Map<Symbol, dynamic> zoneValues);
|
| @@ -82,6 +84,7 @@ abstract class ZoneSpecification {
|
| Duration duration, void f()): null,
|
| Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone,
|
| Duration period, void f(Timer timer)): null,
|
| + void print(Zone self, ZoneDelegate parent, Zone zone, String line): null,
|
| Zone fork(Zone self, ZoneDelegate parent, Zone zone,
|
| ZoneSpecification specification, Map zoneValues): null
|
| }) = _ZoneSpecification;
|
| @@ -112,6 +115,7 @@ abstract class ZoneSpecification {
|
| Duration duration, void f()): null,
|
| Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone,
|
| Duration period, void f(Timer timer)): null,
|
| + void print(Zone self, ZoneDelegate parent, Zone zone, String line): null,
|
| Zone fork(Zone self, ZoneDelegate parent, Zone zone,
|
| ZoneSpecification specification,
|
| Map<Symbol, dynamic> zoneValues): null
|
| @@ -141,6 +145,7 @@ abstract class ZoneSpecification {
|
| createPeriodicTimer: createPeriodicTimer != null
|
| ? createPeriodicTimer
|
| : other.createPeriodicTimer,
|
| + print : print != null ? print : other.print,
|
| fork: fork != null ? fork : other.fork);
|
| }
|
|
|
| @@ -156,6 +161,7 @@ abstract class ZoneSpecification {
|
| RunAsyncHandler get runAsync;
|
| CreateTimerHandler get createTimer;
|
| CreatePeriodicTimerHandler get createPeriodicTimer;
|
| + PrintHandler get print;
|
| ForkHandler get fork;
|
| }
|
|
|
| @@ -179,6 +185,7 @@ class _ZoneSpecification implements ZoneSpecification {
|
| this.runAsync: null,
|
| this.createTimer: null,
|
| this.createPeriodicTimer: null,
|
| + this.print: null,
|
| this.fork: null
|
| });
|
|
|
| @@ -195,6 +202,7 @@ class _ZoneSpecification implements ZoneSpecification {
|
| final /*RunAsyncHandler*/ runAsync;
|
| final /*CreateTimerHandler*/ createTimer;
|
| final /*CreatePeriodicTimerHandler*/ createPeriodicTimer;
|
| + final /*PrintHandler*/ print;
|
| final /*ForkHandler*/ fork;
|
| }
|
|
|
| @@ -224,6 +232,7 @@ abstract class ZoneDelegate {
|
| void scheduleMicrotask(Zone zone, f());
|
| Timer createTimer(Zone zone, Duration duration, void f());
|
| Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer));
|
| + void print(Zone zone, String line);
|
| Zone fork(Zone zone, ZoneSpecification specification, Map zoneValues);
|
| }
|
|
|
| @@ -386,6 +395,11 @@ abstract class Zone {
|
| Timer createPeriodicTimer(Duration period, void callback(Timer timer));
|
|
|
| /**
|
| + * Prints the given [line].
|
| + */
|
| + void print(String line);
|
| +
|
| + /**
|
| * The error zone is the one that is responsible for dealing with uncaught
|
| * errors. Errors are not allowed to cross zones with different error-zones.
|
| */
|
| @@ -507,6 +521,15 @@ class _ZoneDelegate implements ZoneDelegate {
|
| parent, new _ZoneDelegate(parent.parent), zone, period, f);
|
| }
|
|
|
| + void print(Zone zone, String line) {
|
| + _CustomizedZone parent = _degelationTarget;
|
| + while (parent._specification.print == null) {
|
| + parent = parent.parent;
|
| + }
|
| + (parent._specification.print)(
|
| + parent, new _ZoneDelegate(parent.parent), zone, line);
|
| + }
|
| +
|
| Zone fork(Zone zone, ZoneSpecification specification,
|
| Map<Symbol, dynamic> zoneValues) {
|
| _CustomizedZone parent = _degelationTarget;
|
| @@ -651,6 +674,10 @@ class _CustomizedZone implements Zone {
|
| Timer createPeriodicTimer(Duration duration, void f(Timer timer)) {
|
| return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f);
|
| }
|
| +
|
| + void print(String line) {
|
| + new _ZoneDelegate(this).print(this, line);
|
| + }
|
| }
|
|
|
| void _rootHandleUncaughtError(
|
| @@ -735,6 +762,10 @@ Timer _rootCreatePeriodicTimer(
|
| return _createPeriodicTimer(duration, callback);
|
| }
|
|
|
| +void _rootPrint(Zone self, ZoneDelegate parent, Zone zone, String line) {
|
| + internalPrint(line);
|
| +}
|
| +
|
| Zone _rootFork(Zone self, ZoneDelegate parent, Zone zone,
|
| ZoneSpecification specification,
|
| Map<Symbol, dynamic> zoneValues) {
|
| @@ -756,22 +787,83 @@ 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;
|
| + PrintHandler get print => _rootPrint;
|
| + ForkHandler get fork => _rootFork;
|
| +}
|
| +
|
| +class _RootZone extends _CustomizedZone {
|
| + const _RootZone()
|
| + : super(null, const _RootZoneSpecification(), const <Symbol, dynamic>{});
|
| +
|
| + 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);
|
| +
|
| + void print(String line) => _rootPrint(this, null, this, line);
|
| +}
|
| +
|
| +const _ROOT_SPECIFICATION = const _RootZoneSpecification();
|
| +const _ROOT_ZONE = const _RootZone();
|
|
|
|
|
| /**
|
|
|