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

Unified Diff: sdk/lib/io/file_impl.dart

Issue 14196003: Change StreamController constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix some bugs. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index 65f7adfb75586a616a00fd4efb56aed66726a9ea..dd181ce191da00a8eec797cb66bc5c501eba0800 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -47,8 +47,13 @@ class _FileStream extends Stream<List<int>> {
void _setupController() {
_controller = new StreamController<List<int>>(
- onSubscriptionStateChange: _onSubscriptionStateChange,
- onPauseStateChange: _onPauseStateChange);
+ onListen: _start,
+ onPause: () => _paused = true,
+ onResume: _resume,
+ onCancel: () {
+ _unsubscribed = true;
+ _closeFile();
+ });
}
Future _closeFile() {
@@ -128,23 +133,6 @@ class _FileStream extends Stream<List<int>> {
// Resume reading unless we are already done.
if (_openedFile != null) _readBlock();
}
-
- void _onSubscriptionStateChange() {
- if (_controller.hasListener) {
- _start();
- } else {
- _unsubscribed = true;
- _closeFile();
- }
- }
-
- void _onPauseStateChange() {
- if (_controller.isPaused) {
- _paused = true;
- } else {
- _resume();
- }
- }
}
class _FileStreamConsumer extends StreamConsumer<List<int>> {

Powered by Google App Engine
This is Rietveld 408576698