Index: sdk/lib/async/zone.dart |
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart |
index 80184c2e75e67f00ef01e7c42e0f269589dbd582..b5fa0d183c57553589b900d4cf86a2de94dee88d 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) { |
@@ -767,6 +798,7 @@ const _ROOT_SPECIFICATION = const ZoneSpecification( |
scheduleMicrotask: _rootScheduleMicrotask, |
createTimer: _rootCreateTimer, |
createPeriodicTimer: _rootCreatePeriodicTimer, |
+ print: _rootPrint, |
fork: _rootFork |
); |