| OLD | NEW |
| 1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 // Dart core library. | 2 // Dart core library. |
| 3 | 3 |
| 4 class _FutureImpl<T> implements Future<T> { | 4 class _FutureImpl<T> implements Future<T> { |
| 5 | 5 |
| 6 bool _isComplete = false; | 6 bool _isComplete = false; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Value that was provided to this Future by the Completer | 9 * Value that was provided to this Future by the Completer |
| 10 */ | 10 */ |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 final result = transformation(ex); | 228 final result = transformation(ex); |
| 229 | 229 |
| 230 // If the transformation itself returns a future, then we will | 230 // If the transformation itself returns a future, then we will |
| 231 // complete to what that completes to. | 231 // complete to what that completes to. |
| 232 if (result is Future) { | 232 if (result is Future) { |
| 233 _forward(result, completer); | 233 _forward(result, completer); |
| 234 } else { | 234 } else { |
| 235 completer.complete(result); | 235 completer.complete(result); |
| 236 } | 236 } |
| 237 } catch (innerException, stackTrace) { | 237 } catch (innerException, stackTrace) { |
| 238 completer.completeException(innerException, stackTrace); | 238 if (identical(ex, innerException)) { |
| 239 completer.completeException(innerException, this.stackTrace); |
| 240 } else { |
| 241 completer.completeException(innerException, stackTrace); |
| 242 } |
| 239 } | 243 } |
| 240 return false; | 244 return false; |
| 241 }); | 245 }); |
| 242 | 246 |
| 243 _handleSuccess(completer.complete); | 247 _handleSuccess(completer.complete); |
| 244 | 248 |
| 245 return completer.future; | 249 return completer.future; |
| 246 } | 250 } |
| 247 | 251 |
| 248 /** | 252 /** |
| (...skipping 27 matching lines...) Expand all Loading... |
| 276 | 280 |
| 277 void complete(T value) { | 281 void complete(T value) { |
| 278 _futureImpl._setValue(value); | 282 _futureImpl._setValue(value); |
| 279 } | 283 } |
| 280 | 284 |
| 281 void completeException(Object exception, [Object stackTrace]) { | 285 void completeException(Object exception, [Object stackTrace]) { |
| 282 _futureImpl._setException(exception, stackTrace); | 286 _futureImpl._setException(exception, stackTrace); |
| 283 } | 287 } |
| 284 } | 288 } |
| 285 | 289 |
| OLD | NEW |