Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/ | 5 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/ |
| 6 // lands. | 6 // lands. |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "package:async/async.dart" hide ForkableStream, StreamQueue; | 10 import "package:async/async.dart" hide ForkableStream, StreamQueue; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 _completer.complete(_eventsToSkip); | 481 _completer.complete(_eventsToSkip); |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 /// Request for a [StreamQueue.take] call. | 485 /// Request for a [StreamQueue.take] call. |
| 486 class _TakeRequest<T> implements _EventRequest { | 486 class _TakeRequest<T> implements _EventRequest { |
| 487 /// Completer for the future returned by the take call. | 487 /// Completer for the future returned by the take call. |
| 488 final _completer = new Completer<List<T>>(); | 488 final _completer = new Completer<List<T>>(); |
| 489 | 489 |
| 490 /// List collecting events until enough have been seen. | 490 /// List collecting events until enough have been seen. |
| 491 final List _list = <T>[]; | 491 final List<T> _list = <T>[]; |
|
nweiz
2017/03/10 21:24:34
Just make this "final _list".
keertip
2017/03/10 21:30:37
Done.
| |
| 492 | 492 |
| 493 /// Number of events to capture. | 493 /// Number of events to capture. |
| 494 /// | 494 /// |
| 495 /// The request [isComplete] when the length of [_list] reaches | 495 /// The request [isComplete] when the length of [_list] reaches |
| 496 /// this value. | 496 /// this value. |
| 497 final int _eventsToTake; | 497 final int _eventsToTake; |
| 498 | 498 |
| 499 _TakeRequest(this._eventsToTake); | 499 _TakeRequest(this._eventsToTake); |
| 500 | 500 |
| 501 /// The future completed when the correct number of events have been captured. | 501 /// The future completed when the correct number of events have been captured. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 event.addTo(controller); | 688 event.addTo(controller); |
| 689 } | 689 } |
| 690 | 690 |
| 691 var fork = _streamQueue._sourceStream.fork(); | 691 var fork = _streamQueue._sourceStream.fork(); |
| 692 controller.addStream(fork, cancelOnError: false) | 692 controller.addStream(fork, cancelOnError: false) |
| 693 .whenComplete(controller.close); | 693 .whenComplete(controller.close); |
| 694 _completer.setSourceStream(controller.stream); | 694 _completer.setSourceStream(controller.stream); |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 } | 697 } |
| OLD | NEW |