Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: sdk/lib/async/zone.dart

Issue 2762953003: More minor type improvements in dart:async. (Closed)
Patch Set: More fixes. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/async/stream_transformers.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 R ZoneCallback<R>(); 7 typedef R ZoneCallback<R>();
8 typedef R ZoneUnaryCallback<R, T>(T arg); 8 typedef R ZoneUnaryCallback<R, T>(T arg);
9 typedef R ZoneBinaryCallback<R, T1, T2>(T1 arg1, T2 arg2); 9 typedef R ZoneBinaryCallback<R, T1, T2>(T1 arg1, T2 arg2);
10 10
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 * new Future(() { throw "asynchronous error"; }); 1430 * new Future(() { throw "asynchronous error"; });
1431 * }, onError: print); // Will print "asynchronous error". 1431 * }, onError: print); // Will print "asynchronous error".
1432 */ 1432 */
1433 R runZoned<R>(R body(), 1433 R runZoned<R>(R body(),
1434 {Map zoneValues, ZoneSpecification zoneSpecification, Function onError}) { 1434 {Map zoneValues, ZoneSpecification zoneSpecification, Function onError}) {
1435 HandleUncaughtErrorHandler errorHandler; 1435 HandleUncaughtErrorHandler errorHandler;
1436 if (onError != null) { 1436 if (onError != null) {
1437 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error, 1437 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error,
1438 StackTrace stackTrace) { 1438 StackTrace stackTrace) {
1439 try { 1439 try {
1440 if (onError is ZoneBinaryCallback<R, dynamic, StackTrace>) { 1440 if (onError is ZoneBinaryCallback<R, Object, StackTrace>) {
1441 return self.parent.runBinary(onError, error, stackTrace); 1441 return self.parent.runBinary(onError, error, stackTrace);
1442 } 1442 }
1443 return self.parent.runUnary(onError, error); 1443 return self.parent.runUnary(onError, error);
1444 } catch (e, s) { 1444 } catch (e, s) {
1445 if (identical(e, error)) { 1445 if (identical(e, error)) {
1446 return parent.handleUncaughtError(zone, error, stackTrace); 1446 return parent.handleUncaughtError(zone, error, stackTrace);
1447 } else { 1447 } else {
1448 return parent.handleUncaughtError(zone, e, s); 1448 return parent.handleUncaughtError(zone, e, s);
1449 } 1449 }
1450 } 1450 }
1451 }; 1451 };
1452 } 1452 }
1453 if (zoneSpecification == null) { 1453 if (zoneSpecification == null) {
1454 zoneSpecification = 1454 zoneSpecification =
1455 new ZoneSpecification(handleUncaughtError: errorHandler); 1455 new ZoneSpecification(handleUncaughtError: errorHandler);
1456 } else if (errorHandler != null) { 1456 } else if (errorHandler != null) {
1457 zoneSpecification = new ZoneSpecification.from(zoneSpecification, 1457 zoneSpecification = new ZoneSpecification.from(zoneSpecification,
1458 handleUncaughtError: errorHandler); 1458 handleUncaughtError: errorHandler);
1459 } 1459 }
1460 Zone zone = Zone.current 1460 Zone zone = Zone.current
1461 .fork(specification: zoneSpecification, zoneValues: zoneValues); 1461 .fork(specification: zoneSpecification, zoneValues: zoneValues);
1462 if (onError != null) { 1462 if (onError != null) {
1463 return zone.runGuarded(body); 1463 return zone.runGuarded(body);
1464 } else { 1464 } else {
1465 return zone.run(body); 1465 return zone.run(body);
1466 } 1466 }
1467 } 1467 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_transformers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698