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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 assert(implementation != null); | 884 assert(implementation != null); |
885 ZoneDelegate parentDelegate = _parentDelegate(implementation.zone); | 885 ZoneDelegate parentDelegate = _parentDelegate(implementation.zone); |
886 PrintHandler handler = implementation.function; | 886 PrintHandler handler = implementation.function; |
887 return handler(implementation.zone, parentDelegate, this, line); | 887 return handler(implementation.zone, parentDelegate, this, line); |
888 } | 888 } |
889 } | 889 } |
890 | 890 |
891 void _rootHandleUncaughtError( | 891 void _rootHandleUncaughtError( |
892 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { | 892 Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { |
893 _schedulePriorityAsyncCallback(() { | 893 _schedulePriorityAsyncCallback(() { |
894 throw new _UncaughtAsyncError(error, stackTrace); | 894 if (error == null) error = new NullThrownError(); |
turnidge
2015/10/02 21:00:53
Use {}'s here and below.
Lasse Reichstein Nielsen
2015/10/02 22:50:59
We don't generally do that (the surrounding code i
turnidge
2015/10/02 22:54:35
Acknowledged.
| |
895 if (stackTrace == null) throw error; | |
896 _rethrow(error, stackTrace); | |
895 }); | 897 }); |
896 } | 898 } |
897 | 899 |
900 external void _rethrow(Object error, StackTrace stackTrace); | |
Ivan Posva
2015/10/02 23:40:39
Nit: I think it would be better to match the signa
Lasse Reichstein Nielsen
2015/10/05 06:18:49
I think Object is the right type here - it's accep
| |
901 | |
898 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) { | 902 dynamic _rootRun(Zone self, ZoneDelegate parent, Zone zone, f()) { |
899 if (Zone._current == zone) return f(); | 903 if (Zone._current == zone) return f(); |
900 | 904 |
901 Zone old = Zone._enter(zone); | 905 Zone old = Zone._enter(zone); |
902 try { | 906 try { |
903 return f(); | 907 return f(); |
904 } finally { | 908 } finally { |
905 Zone._leave(old); | 909 Zone._leave(old); |
906 } | 910 } |
907 } | 911 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 valueMap = zone._map; | 1006 valueMap = zone._map; |
1003 } else { | 1007 } else { |
1004 valueMap = new HashMap(); | 1008 valueMap = new HashMap(); |
1005 } | 1009 } |
1006 } else { | 1010 } else { |
1007 valueMap = new HashMap.from(zoneValues); | 1011 valueMap = new HashMap.from(zoneValues); |
1008 } | 1012 } |
1009 return new _CustomZone(zone, specification, valueMap); | 1013 return new _CustomZone(zone, specification, valueMap); |
1010 } | 1014 } |
1011 | 1015 |
1012 class _RootZoneSpecification implements ZoneSpecification { | |
1013 HandleUncaughtErrorHandler get handleUncaughtError => | |
1014 _rootHandleUncaughtError; | |
1015 RunHandler get run => _rootRun; | |
1016 RunUnaryHandler get runUnary => _rootRunUnary; | |
1017 RunBinaryHandler get runBinary => _rootRunBinary; | |
1018 RegisterCallbackHandler get registerCallback => _rootRegisterCallback; | |
1019 RegisterUnaryCallbackHandler get registerUnaryCallback => | |
1020 _rootRegisterUnaryCallback; | |
1021 RegisterBinaryCallbackHandler get registerBinaryCallback => | |
1022 _rootRegisterBinaryCallback; | |
1023 ErrorCallbackHandler get errorCallback => _rootErrorCallback; | |
1024 ScheduleMicrotaskHandler get scheduleMicrotask => _rootScheduleMicrotask; | |
1025 CreateTimerHandler get createTimer => _rootCreateTimer; | |
1026 CreatePeriodicTimerHandler get createPeriodicTimer => | |
1027 _rootCreatePeriodicTimer; | |
1028 PrintHandler get print => _rootPrint; | |
1029 ForkHandler get fork => _rootFork; | |
1030 } | |
turnidge
2015/10/02 21:00:53
What's all this about?
Lasse Reichstein Nielsen
2015/10/02 22:50:59
My editor told me the class was unused, so I remov
| |
1031 | |
1032 class _RootZone extends _Zone { | 1016 class _RootZone extends _Zone { |
1033 const _RootZone(); | 1017 const _RootZone(); |
1034 | 1018 |
1035 _ZoneFunction get _run => | 1019 _ZoneFunction get _run => |
1036 const _ZoneFunction(_ROOT_ZONE, _rootRun); | 1020 const _ZoneFunction(_ROOT_ZONE, _rootRun); |
1037 _ZoneFunction get _runUnary => | 1021 _ZoneFunction get _runUnary => |
1038 const _ZoneFunction(_ROOT_ZONE, _rootRunUnary); | 1022 const _ZoneFunction(_ROOT_ZONE, _rootRunUnary); |
1039 _ZoneFunction get _runBinary => | 1023 _ZoneFunction get _runBinary => |
1040 const _ZoneFunction(_ROOT_ZONE, _rootRunBinary); | 1024 const _ZoneFunction(_ROOT_ZONE, _rootRunBinary); |
1041 _ZoneFunction get _registerCallback => | 1025 _ZoneFunction get _registerCallback => |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1254 handleUncaughtError: errorHandler); | 1238 handleUncaughtError: errorHandler); |
1255 } | 1239 } |
1256 Zone zone = Zone.current.fork(specification: zoneSpecification, | 1240 Zone zone = Zone.current.fork(specification: zoneSpecification, |
1257 zoneValues: zoneValues); | 1241 zoneValues: zoneValues); |
1258 if (onError != null) { | 1242 if (onError != null) { |
1259 return zone.runGuarded(body); | 1243 return zone.runGuarded(body); |
1260 } else { | 1244 } else { |
1261 return zone.run(body); | 1245 return zone.run(body); |
1262 } | 1246 } |
1263 } | 1247 } |
OLD | NEW |