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

Side by Side Diff: sdk/lib/io/file_impl.dart

Issue 51883004: Let the stream of File:openRead handle cancel correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | tests/standalone/io/directory_list_pause_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 cancelOnError: cancelOnError); 47 cancelOnError: cancelOnError);
48 } 48 }
49 49
50 void _setupController() { 50 void _setupController() {
51 _controller = new StreamController<List<int>>(sync: true, 51 _controller = new StreamController<List<int>>(sync: true,
52 onListen: _start, 52 onListen: _start,
53 onPause: () => _paused = true, 53 onPause: () => _paused = true,
54 onResume: _resume, 54 onResume: _resume,
55 onCancel: () { 55 onCancel: () {
56 _unsubscribed = true; 56 _unsubscribed = true;
57 _closeFile(); 57 return _closeFile();
58 }); 58 });
59 } 59 }
60 60
61 Future _closeFile() { 61 Future _closeFile() {
62 if (_readInProgress) { 62 if (_readInProgress) {
63 return _closeCompleter.future; 63 return _closeCompleter.future;
64 } 64 }
65 if (_openedFile != null) { 65 if (_openedFile != null) {
66 _openedFile.close() 66 _openedFile.close()
67 .then(_closeCompleter.complete, 67 .then(_closeCompleter.complete,
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 void _checkAvailable() { 868 void _checkAvailable() {
869 if (_asyncDispatched) { 869 if (_asyncDispatched) {
870 throw new FileSystemException("An async operation is currently pending", p ath); 870 throw new FileSystemException("An async operation is currently pending", p ath);
871 } 871 }
872 if (closed) { 872 if (closed) {
873 throw new FileSystemException("File closed", path); 873 throw new FileSystemException("File closed", path);
874 } 874 }
875 } 875 }
876 } 876 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/directory_list_pause_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698