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

Side by Side Diff: lib/html/src/Measurement.dart

Issue 10891022: Update corelib/ and lib/ to use the new try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 typedef Object ComputeValue(); 5 typedef Object ComputeValue();
6 6
7 class _MeasurementRequest<T> { 7 class _MeasurementRequest<T> {
8 final ComputeValue computeValue; 8 final ComputeValue computeValue;
9 final Completer<T> completer; 9 final Completer<T> completer;
10 Object value; 10 Object value;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 _nextMeasurementFrameScheduled = false; 85 _nextMeasurementFrameScheduled = false;
86 // We must compute all new values before fulfilling the futures as 86 // We must compute all new values before fulfilling the futures as
87 // the onComplete callbacks for the futures could modify the DOM making 87 // the onComplete callbacks for the futures could modify the DOM making
88 // subsequent measurement calculations expensive to compute. 88 // subsequent measurement calculations expensive to compute.
89 if (_pendingRequests !== null) { 89 if (_pendingRequests !== null) {
90 for (_MeasurementRequest request in _pendingRequests) { 90 for (_MeasurementRequest request in _pendingRequests) {
91 try { 91 try {
92 request.value = request.computeValue(); 92 request.value = request.computeValue();
93 } catch(var e) { 93 } catch (e) {
94 request.value = e; 94 request.value = e;
95 request.exception = true; 95 request.exception = true;
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 final completedRequests = _pendingRequests; 100 final completedRequests = _pendingRequests;
101 final readyMeasurementFrameCallbacks = _pendingMeasurementFrameCallbacks; 101 final readyMeasurementFrameCallbacks = _pendingMeasurementFrameCallbacks;
102 _pendingRequests = null; 102 _pendingRequests = null;
103 _pendingMeasurementFrameCallbacks = null; 103 _pendingMeasurementFrameCallbacks = null;
104 if (completedRequests !== null) { 104 if (completedRequests !== null) {
105 for (_MeasurementRequest request in completedRequests) { 105 for (_MeasurementRequest request in completedRequests) {
106 if (request.exception) { 106 if (request.exception) {
107 request.completer.completeException(request.value); 107 request.completer.completeException(request.value);
108 } else { 108 } else {
109 request.completer.complete(request.value); 109 request.completer.complete(request.value);
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 if (readyMeasurementFrameCallbacks !== null) { 114 if (readyMeasurementFrameCallbacks !== null) {
115 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { 115 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) {
116 // TODO(jacobr): wrap each call to a handler in a try-catch block. 116 // TODO(jacobr): wrap each call to a handler in a try-catch block.
117 handler(); 117 handler();
118 } 118 }
119 } 119 }
120 } 120 }
OLDNEW
« no previous file with comments | « lib/html/src/AnimationEventWrappingImplementation.dart ('k') | lib/html/src/XMLElementWrappingImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698