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

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

Issue 228093003: Make File:openRead always have one outstanding read, when invoking callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « no previous file | tests/standalone/io/file_input_stream_test.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 aa2e495645abb0a6464a060656daad4b7adf2f42..05c33f605b68581652762c514dd82c05b6dd9c90 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -95,20 +95,23 @@ class _FileStream extends Stream<List<int>> {
}
_openedFile.read(readBytes)
.then((block) {
+ _readInProgress = false;
if (_unsubscribed) {
_closeFile();
return;
}
- _readInProgress = false;
_position += block.length;
if (block.length < readBytes ||
(_end != null && _position == _end)) {
_atEnd = true;
}
- _controller.add(block);
- if (!_controller.isPaused) {
+ if (!_atEnd && !_controller.isPaused) {
_readBlock();
}
+ _controller.add(block);
+ if (_atEnd) {
+ _closeFile();
+ }
})
.catchError((e, s) {
if (!_unsubscribed) {
« no previous file with comments | « no previous file | tests/standalone/io/file_input_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698