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

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: Address comments and rebase. 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
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index d1569d7a6e0cfe5ad964542d470c5c669abd6bf9..9b557ba3bf4620ef331065807909f4732b1171bd 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>> {
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698