| 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 13 matching lines...) Expand all Loading... |
| 24 typedef void ScheduleMicrotaskHandler( | 24 typedef void ScheduleMicrotaskHandler( |
| 25 Zone self, ZoneDelegate parent, Zone zone, f()); | 25 Zone self, ZoneDelegate parent, Zone zone, f()); |
| 26 @deprecated | 26 @deprecated |
| 27 typedef void RunAsyncHandler( | 27 typedef void RunAsyncHandler( |
| 28 Zone self, ZoneDelegate parent, Zone zone, f()); | 28 Zone self, ZoneDelegate parent, Zone zone, f()); |
| 29 typedef Timer CreateTimerHandler( | 29 typedef Timer CreateTimerHandler( |
| 30 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()); | 30 Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()); |
| 31 typedef Timer CreatePeriodicTimerHandler( | 31 typedef Timer CreatePeriodicTimerHandler( |
| 32 Zone self, ZoneDelegate parent, Zone zone, | 32 Zone self, ZoneDelegate parent, Zone zone, |
| 33 Duration period, void f(Timer timer)); | 33 Duration period, void f(Timer timer)); |
| 34 typedef void PrintHandler( |
| 35 Zone self, ZoneDelegate parent, Zone zone, String line); |
| 34 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone, | 36 typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone, |
| 35 ZoneSpecification specification, | 37 ZoneSpecification specification, |
| 36 Map<Symbol, dynamic> zoneValues); | 38 Map<Symbol, dynamic> zoneValues); |
| 37 | 39 |
| 38 /** | 40 /** |
| 39 * This class provides the specification for a forked zone. | 41 * This class provides the specification for a forked zone. |
| 40 * | 42 * |
| 41 * When forking a new zone (see [Zone.fork]) one can override the default | 43 * When forking a new zone (see [Zone.fork]) one can override the default |
| 42 * behavior of the zone by providing callbacks. These callbacks must be | 44 * behavior of the zone by providing callbacks. These callbacks must be |
| 43 * given in an instance of this class. | 45 * given in an instance of this class. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ZoneBinaryCallback registerBinaryCallback( | 77 ZoneBinaryCallback registerBinaryCallback( |
| 76 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null, | 78 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null, |
| 77 void scheduleMicrotask( | 79 void scheduleMicrotask( |
| 78 Zone self, ZoneDelegate parent, Zone zone, f()): null, | 80 Zone self, ZoneDelegate parent, Zone zone, f()): null, |
| 79 void runAsync( | 81 void runAsync( |
| 80 Zone self, ZoneDelegate parent, Zone zone, f()): null, | 82 Zone self, ZoneDelegate parent, Zone zone, f()): null, |
| 81 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, | 83 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, |
| 82 Duration duration, void f()): null, | 84 Duration duration, void f()): null, |
| 83 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, | 85 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, |
| 84 Duration period, void f(Timer timer)): null, | 86 Duration period, void f(Timer timer)): null, |
| 87 void print(Zone self, ZoneDelegate parent, Zone zone, String line): null, |
| 85 Zone fork(Zone self, ZoneDelegate parent, Zone zone, | 88 Zone fork(Zone self, ZoneDelegate parent, Zone zone, |
| 86 ZoneSpecification specification, Map zoneValues): null | 89 ZoneSpecification specification, Map zoneValues): null |
| 87 }) = _ZoneSpecification; | 90 }) = _ZoneSpecification; |
| 88 | 91 |
| 89 /** | 92 /** |
| 90 * Creates a specification from [other] with the provided handlers overriding | 93 * Creates a specification from [other] with the provided handlers overriding |
| 91 * the ones in [other]. | 94 * the ones in [other]. |
| 92 */ | 95 */ |
| 93 factory ZoneSpecification.from(ZoneSpecification other, { | 96 factory ZoneSpecification.from(ZoneSpecification other, { |
| 94 dynamic handleUncaughtError(Zone self, ZoneDelegate parent, Zone zone, | 97 dynamic handleUncaughtError(Zone self, ZoneDelegate parent, Zone zone, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 105 ZoneBinaryCallback registerBinaryCallback( | 108 ZoneBinaryCallback registerBinaryCallback( |
| 106 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null, | 109 Zone self, ZoneDelegate parent, Zone zone, f(arg1, arg2)): null, |
| 107 void scheduleMicrotask( | 110 void scheduleMicrotask( |
| 108 Zone self, ZoneDelegate parent, Zone zone, f()): null, | 111 Zone self, ZoneDelegate parent, Zone zone, f()): null, |
| 109 void runAsync( | 112 void runAsync( |
| 110 Zone self, ZoneDelegate parent, Zone zone, f()): null, | 113 Zone self, ZoneDelegate parent, Zone zone, f()): null, |
| 111 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, | 114 Timer createTimer(Zone self, ZoneDelegate parent, Zone zone, |
| 112 Duration duration, void f()): null, | 115 Duration duration, void f()): null, |
| 113 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, | 116 Timer createPeriodicTimer(Zone self, ZoneDelegate parent, Zone zone, |
| 114 Duration period, void f(Timer timer)): null, | 117 Duration period, void f(Timer timer)): null, |
| 118 void print(Zone self, ZoneDelegate parent, Zone zone, String line): null, |
| 115 Zone fork(Zone self, ZoneDelegate parent, Zone zone, | 119 Zone fork(Zone self, ZoneDelegate parent, Zone zone, |
| 116 ZoneSpecification specification, | 120 ZoneSpecification specification, |
| 117 Map<Symbol, dynamic> zoneValues): null | 121 Map<Symbol, dynamic> zoneValues): null |
| 118 }) { | 122 }) { |
| 119 return new ZoneSpecification( | 123 return new ZoneSpecification( |
| 120 handleUncaughtError: handleUncaughtError != null | 124 handleUncaughtError: handleUncaughtError != null |
| 121 ? handleUncaughtError | 125 ? handleUncaughtError |
| 122 : other.handleUncaughtError, | 126 : other.handleUncaughtError, |
| 123 run: run != null ? run : other.run, | 127 run: run != null ? run : other.run, |
| 124 runUnary: runUnary != null ? runUnary : other.runUnary, | 128 runUnary: runUnary != null ? runUnary : other.runUnary, |
| 125 runBinary: runBinary != null ? runBinary : other.runBinary, | 129 runBinary: runBinary != null ? runBinary : other.runBinary, |
| 126 registerCallback: registerCallback != null | 130 registerCallback: registerCallback != null |
| 127 ? registerCallback | 131 ? registerCallback |
| 128 : other.registerCallback, | 132 : other.registerCallback, |
| 129 registerUnaryCallback: registerUnaryCallback != null | 133 registerUnaryCallback: registerUnaryCallback != null |
| 130 ? registerUnaryCallback | 134 ? registerUnaryCallback |
| 131 : other.registerUnaryCallback, | 135 : other.registerUnaryCallback, |
| 132 registerBinaryCallback: registerBinaryCallback != null | 136 registerBinaryCallback: registerBinaryCallback != null |
| 133 ? registerBinaryCallback | 137 ? registerBinaryCallback |
| 134 : other.registerBinaryCallback, | 138 : other.registerBinaryCallback, |
| 135 scheduleMicrotask: scheduleMicrotask != null | 139 scheduleMicrotask: scheduleMicrotask != null |
| 136 ? scheduleMicrotask | 140 ? scheduleMicrotask |
| 137 : (runAsync != null | 141 : (runAsync != null |
| 138 ? runAsync | 142 ? runAsync |
| 139 : other.scheduleMicrotask), | 143 : other.scheduleMicrotask), |
| 140 createTimer : createTimer != null ? createTimer : other.createTimer, | 144 createTimer : createTimer != null ? createTimer : other.createTimer, |
| 141 createPeriodicTimer: createPeriodicTimer != null | 145 createPeriodicTimer: createPeriodicTimer != null |
| 142 ? createPeriodicTimer | 146 ? createPeriodicTimer |
| 143 : other.createPeriodicTimer, | 147 : other.createPeriodicTimer, |
| 148 print : print != null ? print : other.print, |
| 144 fork: fork != null ? fork : other.fork); | 149 fork: fork != null ? fork : other.fork); |
| 145 } | 150 } |
| 146 | 151 |
| 147 HandleUncaughtErrorHandler get handleUncaughtError; | 152 HandleUncaughtErrorHandler get handleUncaughtError; |
| 148 RunHandler get run; | 153 RunHandler get run; |
| 149 RunUnaryHandler get runUnary; | 154 RunUnaryHandler get runUnary; |
| 150 RunBinaryHandler get runBinary; | 155 RunBinaryHandler get runBinary; |
| 151 RegisterCallbackHandler get registerCallback; | 156 RegisterCallbackHandler get registerCallback; |
| 152 RegisterUnaryCallbackHandler get registerUnaryCallback; | 157 RegisterUnaryCallbackHandler get registerUnaryCallback; |
| 153 RegisterBinaryCallbackHandler get registerBinaryCallback; | 158 RegisterBinaryCallbackHandler get registerBinaryCallback; |
| 154 ScheduleMicrotaskHandler get scheduleMicrotask; | 159 ScheduleMicrotaskHandler get scheduleMicrotask; |
| 155 @deprecated | 160 @deprecated |
| 156 RunAsyncHandler get runAsync; | 161 RunAsyncHandler get runAsync; |
| 157 CreateTimerHandler get createTimer; | 162 CreateTimerHandler get createTimer; |
| 158 CreatePeriodicTimerHandler get createPeriodicTimer; | 163 CreatePeriodicTimerHandler get createPeriodicTimer; |
| 164 PrintHandler get print; |
| 159 ForkHandler get fork; | 165 ForkHandler get fork; |
| 160 } | 166 } |
| 161 | 167 |
| 162 /** | 168 /** |
| 163 * Internal [ZoneSpecification] class. | 169 * Internal [ZoneSpecification] class. |
| 164 * | 170 * |
| 165 * The implementation wants to rely on the fact that the getters cannot change | 171 * The implementation wants to rely on the fact that the getters cannot change |
| 166 * dynamically. We thus require users to go through the redirecting | 172 * dynamically. We thus require users to go through the redirecting |
| 167 * [ZoneSpecification] constructor which instantiates this class. | 173 * [ZoneSpecification] constructor which instantiates this class. |
| 168 */ | 174 */ |
| 169 class _ZoneSpecification implements ZoneSpecification { | 175 class _ZoneSpecification implements ZoneSpecification { |
| 170 const _ZoneSpecification({ | 176 const _ZoneSpecification({ |
| 171 this.handleUncaughtError: null, | 177 this.handleUncaughtError: null, |
| 172 this.run: null, | 178 this.run: null, |
| 173 this.runUnary: null, | 179 this.runUnary: null, |
| 174 this.runBinary: null, | 180 this.runBinary: null, |
| 175 this.registerCallback: null, | 181 this.registerCallback: null, |
| 176 this.registerUnaryCallback: null, | 182 this.registerUnaryCallback: null, |
| 177 this.registerBinaryCallback: null, | 183 this.registerBinaryCallback: null, |
| 178 this.scheduleMicrotask: null, | 184 this.scheduleMicrotask: null, |
| 179 this.runAsync: null, | 185 this.runAsync: null, |
| 180 this.createTimer: null, | 186 this.createTimer: null, |
| 181 this.createPeriodicTimer: null, | 187 this.createPeriodicTimer: null, |
| 188 this.print: null, |
| 182 this.fork: null | 189 this.fork: null |
| 183 }); | 190 }); |
| 184 | 191 |
| 185 // TODO(13406): Enable types when dart2js supports it. | 192 // TODO(13406): Enable types when dart2js supports it. |
| 186 final /*HandleUncaughtErrorHandler*/ handleUncaughtError; | 193 final /*HandleUncaughtErrorHandler*/ handleUncaughtError; |
| 187 final /*RunHandler*/ run; | 194 final /*RunHandler*/ run; |
| 188 final /*RunUnaryHandler*/ runUnary; | 195 final /*RunUnaryHandler*/ runUnary; |
| 189 final /*RunBinaryHandler*/ runBinary; | 196 final /*RunBinaryHandler*/ runBinary; |
| 190 final /*RegisterCallbackHandler*/ registerCallback; | 197 final /*RegisterCallbackHandler*/ registerCallback; |
| 191 final /*RegisterUnaryCallbackHandler*/ registerUnaryCallback; | 198 final /*RegisterUnaryCallbackHandler*/ registerUnaryCallback; |
| 192 final /*RegisterBinaryCallbackHandler*/ registerBinaryCallback; | 199 final /*RegisterBinaryCallbackHandler*/ registerBinaryCallback; |
| 193 final /*ScheduleMicrotaskHandler*/ scheduleMicrotask; | 200 final /*ScheduleMicrotaskHandler*/ scheduleMicrotask; |
| 194 @deprecated | 201 @deprecated |
| 195 final /*RunAsyncHandler*/ runAsync; | 202 final /*RunAsyncHandler*/ runAsync; |
| 196 final /*CreateTimerHandler*/ createTimer; | 203 final /*CreateTimerHandler*/ createTimer; |
| 197 final /*CreatePeriodicTimerHandler*/ createPeriodicTimer; | 204 final /*CreatePeriodicTimerHandler*/ createPeriodicTimer; |
| 205 final /*PrintHandler*/ print; |
| 198 final /*ForkHandler*/ fork; | 206 final /*ForkHandler*/ fork; |
| 199 } | 207 } |
| 200 | 208 |
| 201 /** | 209 /** |
| 202 * This class wraps zones for delegation. | 210 * This class wraps zones for delegation. |
| 203 * | 211 * |
| 204 * When forwarding to parent zones one can't just invoke the parent zone's | 212 * When forwarding to parent zones one can't just invoke the parent zone's |
| 205 * exposed functions (like [Zone.run]), but one needs to provide more | 213 * exposed functions (like [Zone.run]), but one needs to provide more |
| 206 * information (like the zone the `run` was initiated). Zone callbacks thus | 214 * information (like the zone the `run` was initiated). Zone callbacks thus |
| 207 * receive more information including this [ZoneDelegate] class. When delegating | 215 * receive more information including this [ZoneDelegate] class. When delegating |
| 208 * to the parent zone one should go through the given instance instead of | 216 * to the parent zone one should go through the given instance instead of |
| 209 * directly invoking the parent zone. | 217 * directly invoking the parent zone. |
| 210 */ | 218 */ |
| 211 abstract class ZoneDelegate { | 219 abstract class ZoneDelegate { |
| 212 /// The [Zone] this class wraps. | 220 /// The [Zone] this class wraps. |
| 213 Zone get _zone; | 221 Zone get _zone; |
| 214 | 222 |
| 215 dynamic handleUncaughtError(Zone zone, error, StackTrace stackTrace); | 223 dynamic handleUncaughtError(Zone zone, error, StackTrace stackTrace); |
| 216 dynamic run(Zone zone, f()); | 224 dynamic run(Zone zone, f()); |
| 217 dynamic runUnary(Zone zone, f(arg), arg); | 225 dynamic runUnary(Zone zone, f(arg), arg); |
| 218 dynamic runBinary(Zone zone, f(arg1, arg2), arg1, arg2); | 226 dynamic runBinary(Zone zone, f(arg1, arg2), arg1, arg2); |
| 219 ZoneCallback registerCallback(Zone zone, f()); | 227 ZoneCallback registerCallback(Zone zone, f()); |
| 220 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg)); | 228 ZoneUnaryCallback registerUnaryCallback(Zone zone, f(arg)); |
| 221 ZoneBinaryCallback registerBinaryCallback(Zone zone, f(arg1, arg2)); | 229 ZoneBinaryCallback registerBinaryCallback(Zone zone, f(arg1, arg2)); |
| 222 @deprecated | 230 @deprecated |
| 223 void runAsync(Zone zone, f()); | 231 void runAsync(Zone zone, f()); |
| 224 void scheduleMicrotask(Zone zone, f()); | 232 void scheduleMicrotask(Zone zone, f()); |
| 225 Timer createTimer(Zone zone, Duration duration, void f()); | 233 Timer createTimer(Zone zone, Duration duration, void f()); |
| 226 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer)); | 234 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer)); |
| 235 void print(Zone zone, String line); |
| 227 Zone fork(Zone zone, ZoneSpecification specification, Map zoneValues); | 236 Zone fork(Zone zone, ZoneSpecification specification, Map zoneValues); |
| 228 } | 237 } |
| 229 | 238 |
| 230 /** | 239 /** |
| 231 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous | 240 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous |
| 232 * callbacks are executed in the zone they have been queued in. For example, | 241 * callbacks are executed in the zone they have been queued in. For example, |
| 233 * the callback of a `future.then` is executed in the same zone as the one where | 242 * the callback of a `future.then` is executed in the same zone as the one where |
| 234 * the `then` was invoked. | 243 * the `then` was invoked. |
| 235 */ | 244 */ |
| 236 abstract class Zone { | 245 abstract class Zone { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 * Creates a Timer where the callback is executed in this zone. | 388 * Creates a Timer where the callback is executed in this zone. |
| 380 */ | 389 */ |
| 381 Timer createTimer(Duration duration, void callback()); | 390 Timer createTimer(Duration duration, void callback()); |
| 382 | 391 |
| 383 /** | 392 /** |
| 384 * Creates a periodic Timer where the callback is executed in this zone. | 393 * Creates a periodic Timer where the callback is executed in this zone. |
| 385 */ | 394 */ |
| 386 Timer createPeriodicTimer(Duration period, void callback(Timer timer)); | 395 Timer createPeriodicTimer(Duration period, void callback(Timer timer)); |
| 387 | 396 |
| 388 /** | 397 /** |
| 398 * Prints the given [line]. |
| 399 */ |
| 400 void print(String line); |
| 401 |
| 402 /** |
| 389 * The error zone is the one that is responsible for dealing with uncaught | 403 * The error zone is the one that is responsible for dealing with uncaught |
| 390 * errors. Errors are not allowed to cross zones with different error-zones. | 404 * errors. Errors are not allowed to cross zones with different error-zones. |
| 391 */ | 405 */ |
| 392 Zone get _errorZone; | 406 Zone get _errorZone; |
| 393 | 407 |
| 394 /** | 408 /** |
| 395 * Retrieves the zone-value associated with [key]. | 409 * Retrieves the zone-value associated with [key]. |
| 396 * | 410 * |
| 397 * If this zone does not contain the value looks up the same key in the | 411 * If this zone does not contain the value looks up the same key in the |
| 398 * parent zone. If the [key] is not found returns `null`. | 412 * parent zone. If the [key] is not found returns `null`. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 514 |
| 501 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer)) { | 515 Timer createPeriodicTimer(Zone zone, Duration period, void f(Timer timer)) { |
| 502 _CustomizedZone parent = _degelationTarget; | 516 _CustomizedZone parent = _degelationTarget; |
| 503 while (parent._specification.createPeriodicTimer == null) { | 517 while (parent._specification.createPeriodicTimer == null) { |
| 504 parent = parent.parent; | 518 parent = parent.parent; |
| 505 } | 519 } |
| 506 return (parent._specification.createPeriodicTimer)( | 520 return (parent._specification.createPeriodicTimer)( |
| 507 parent, new _ZoneDelegate(parent.parent), zone, period, f); | 521 parent, new _ZoneDelegate(parent.parent), zone, period, f); |
| 508 } | 522 } |
| 509 | 523 |
| 524 void print(Zone zone, String line) { |
| 525 _CustomizedZone parent = _degelationTarget; |
| 526 while (parent._specification.print == null) { |
| 527 parent = parent.parent; |
| 528 } |
| 529 (parent._specification.print)( |
| 530 parent, new _ZoneDelegate(parent.parent), zone, line); |
| 531 } |
| 532 |
| 510 Zone fork(Zone zone, ZoneSpecification specification, | 533 Zone fork(Zone zone, ZoneSpecification specification, |
| 511 Map<Symbol, dynamic> zoneValues) { | 534 Map<Symbol, dynamic> zoneValues) { |
| 512 _CustomizedZone parent = _degelationTarget; | 535 _CustomizedZone parent = _degelationTarget; |
| 513 while (parent._specification.fork == null) { | 536 while (parent._specification.fork == null) { |
| 514 parent = parent.parent; | 537 parent = parent.parent; |
| 515 } | 538 } |
| 516 _ZoneDelegate grandParent = new _ZoneDelegate(parent.parent); | 539 _ZoneDelegate grandParent = new _ZoneDelegate(parent.parent); |
| 517 return (parent._specification.fork)( | 540 return (parent._specification.fork)( |
| 518 parent, grandParent, zone, specification, zoneValues); | 541 parent, grandParent, zone, specification, zoneValues); |
| 519 } | 542 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 scheduleMicrotask(f); | 667 scheduleMicrotask(f); |
| 645 } | 668 } |
| 646 | 669 |
| 647 Timer createTimer(Duration duration, void f()) { | 670 Timer createTimer(Duration duration, void f()) { |
| 648 return new _ZoneDelegate(this).createTimer(this, duration, f); | 671 return new _ZoneDelegate(this).createTimer(this, duration, f); |
| 649 } | 672 } |
| 650 | 673 |
| 651 Timer createPeriodicTimer(Duration duration, void f(Timer timer)) { | 674 Timer createPeriodicTimer(Duration duration, void f(Timer timer)) { |
| 652 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f); | 675 return new _ZoneDelegate(this).createPeriodicTimer(this, duration, f); |
| 653 } | 676 } |
| 677 |
| 678 void print(String line) { |
| 679 new _ZoneDelegate(this).print(this, line); |
| 680 } |
| 654 } | 681 } |
| 655 | 682 |
| 656 void _rootHandleUncaughtError( | 683 void _rootHandleUncaughtError( |
| 657 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { | 684 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { |
| 658 _scheduleAsyncCallback(() { | 685 _scheduleAsyncCallback(() { |
| 659 print("Uncaught Error: ${error}"); | 686 print("Uncaught Error: ${error}"); |
| 660 var trace = stackTrace; | 687 var trace = stackTrace; |
| 661 if (trace == null) trace = getAttachedStackTrace(error); | 688 if (trace == null) trace = getAttachedStackTrace(error); |
| 662 // Clear the attached stack trace (if any). | 689 // Clear the attached stack trace (if any). |
| 663 _attachStackTrace(error, null); | 690 _attachStackTrace(error, null); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 Duration duration, void callback()) { | 755 Duration duration, void callback()) { |
| 729 return _createTimer(duration, callback); | 756 return _createTimer(duration, callback); |
| 730 } | 757 } |
| 731 | 758 |
| 732 Timer _rootCreatePeriodicTimer( | 759 Timer _rootCreatePeriodicTimer( |
| 733 Zone self, ZoneDelegate parent, Zone zone, | 760 Zone self, ZoneDelegate parent, Zone zone, |
| 734 Duration duration, void callback(Timer timer)) { | 761 Duration duration, void callback(Timer timer)) { |
| 735 return _createPeriodicTimer(duration, callback); | 762 return _createPeriodicTimer(duration, callback); |
| 736 } | 763 } |
| 737 | 764 |
| 765 void _rootPrint(Zone self, ZoneDelegate parent, Zone zone, String line) { |
| 766 internalPrint(line); |
| 767 } |
| 768 |
| 738 Zone _rootFork(Zone self, ZoneDelegate parent, Zone zone, | 769 Zone _rootFork(Zone self, ZoneDelegate parent, Zone zone, |
| 739 ZoneSpecification specification, | 770 ZoneSpecification specification, |
| 740 Map<Symbol, dynamic> zoneValues) { | 771 Map<Symbol, dynamic> zoneValues) { |
| 741 if (specification == null) { | 772 if (specification == null) { |
| 742 specification = const ZoneSpecification(); | 773 specification = const ZoneSpecification(); |
| 743 } else if (specification is! _ZoneSpecification) { | 774 } else if (specification is! _ZoneSpecification) { |
| 744 throw new ArgumentError("ZoneSpecifications must be instantiated" | 775 throw new ArgumentError("ZoneSpecifications must be instantiated" |
| 745 " with the provided constructor."); | 776 " with the provided constructor."); |
| 746 } | 777 } |
| 747 Map<Symbol, dynamic> copiedMap = new HashMap(); | 778 Map<Symbol, dynamic> copiedMap = new HashMap(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 760 handleUncaughtError: _rootHandleUncaughtError, | 791 handleUncaughtError: _rootHandleUncaughtError, |
| 761 run: _rootRun, | 792 run: _rootRun, |
| 762 runUnary: _rootRunUnary, | 793 runUnary: _rootRunUnary, |
| 763 runBinary: _rootRunBinary, | 794 runBinary: _rootRunBinary, |
| 764 registerCallback: _rootRegisterCallback, | 795 registerCallback: _rootRegisterCallback, |
| 765 registerUnaryCallback: _rootRegisterUnaryCallback, | 796 registerUnaryCallback: _rootRegisterUnaryCallback, |
| 766 registerBinaryCallback: _rootRegisterBinaryCallback, | 797 registerBinaryCallback: _rootRegisterBinaryCallback, |
| 767 scheduleMicrotask: _rootScheduleMicrotask, | 798 scheduleMicrotask: _rootScheduleMicrotask, |
| 768 createTimer: _rootCreateTimer, | 799 createTimer: _rootCreateTimer, |
| 769 createPeriodicTimer: _rootCreatePeriodicTimer, | 800 createPeriodicTimer: _rootCreatePeriodicTimer, |
| 801 print: _rootPrint, |
| 770 fork: _rootFork | 802 fork: _rootFork |
| 771 ); | 803 ); |
| 772 | 804 |
| 773 const _ROOT_ZONE = | 805 const _ROOT_ZONE = |
| 774 const _CustomizedZone(null, _ROOT_SPECIFICATION, const <Symbol, dynamic>{}); | 806 const _CustomizedZone(null, _ROOT_SPECIFICATION, const <Symbol, dynamic>{}); |
| 775 | 807 |
| 776 | 808 |
| 777 /** | 809 /** |
| 778 * Runs [body] in its own zone. | 810 * Runs [body] in its own zone. |
| 779 * | 811 * |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 ZoneSpecification specification = | 923 ZoneSpecification specification = |
| 892 new ZoneSpecification(handleUncaughtError: errorHandler, | 924 new ZoneSpecification(handleUncaughtError: errorHandler, |
| 893 scheduleMicrotask: asyncHandler); | 925 scheduleMicrotask: asyncHandler); |
| 894 Zone zone = Zone.current.fork(specification: specification); | 926 Zone zone = Zone.current.fork(specification: specification); |
| 895 if (onError != null) { | 927 if (onError != null) { |
| 896 return zone.runGuarded(body); | 928 return zone.runGuarded(body); |
| 897 } else { | 929 } else { |
| 898 return zone.run(body); | 930 return zone.run(body); |
| 899 } | 931 } |
| 900 } | 932 } |
| OLD | NEW |