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

Side by Side Diff: runtime/bin/file_impl.dart

Issue 10543078: Fix dart:io File.openInputStream input stream to cancel outstanding onData events when EOF reached. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _FileInputStream extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(String name) 6 _FileInputStream(String name)
7 : _data = [], 7 : _data = [],
8 _position = 0, 8 _position = 0,
9 _filePosition = 0 { 9 _filePosition = 0 {
10 var file = new File(name); 10 var file = new File(name);
(...skipping 20 matching lines...) Expand all
31 return _fillBuffer(); 31 return _fillBuffer();
32 }); 32 });
33 chained.handleException((e) { 33 chained.handleException((e) {
34 _reportError(e); 34 _reportError(e);
35 return true; 35 return true;
36 }); 36 });
37 chained.then((ignored) => _checkScheduleCallbacks()); 37 chained.then((ignored) => _checkScheduleCallbacks());
38 } 38 }
39 39
40 void _closeFile() { 40 void _closeFile() {
41 if (available() == 0) _cancelScheduledDataCallback();
41 if (!_openedFile.closed) { 42 if (!_openedFile.closed) {
42 _openedFile.close().then((ignore) { 43 _openedFile.close().then((ignore) {
43 _streamMarkedClosed = true; 44 _streamMarkedClosed = true;
44 _checkScheduleCallbacks(); 45 _checkScheduleCallbacks();
45 }); 46 });
46 } 47 }
47 } 48 }
48 49
49 Future<int> _fillBuffer() { 50 Future<int> _fillBuffer() {
50 Expect.equals(_position, _data.length); 51 Expect.equals(_position, _data.length);
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 new FileIOException("File closed '$_name'")); 1132 new FileIOException("File closed '$_name'"));
1132 }); 1133 });
1133 return completer.future; 1134 return completer.future;
1134 } 1135 }
1135 1136
1136 final String _name; 1137 final String _name;
1137 int _id; 1138 int _id;
1138 1139
1139 SendPort _fileService; 1140 SendPort _fileService;
1140 } 1141 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698