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

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

Issue 9072004: Make sure to close when _BaseDataInputStream reaches the end (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | « runtime/bin/file_impl.dart ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 _BaseDataInputStream { 5 class _BaseDataInputStream {
6 abstract int available(); 6 abstract int available();
7 7
8 List<int> read([int len]) { 8 List<int> read([int len]) {
9 if (_closeCallbackCalled) return null; 9 if (_closeCallbackCalled) return null;
10 int bytesToRead = available(); 10 int bytesToRead = available();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Schedule data callback if there is more data to read. Schedule 76 // Schedule data callback if there is more data to read. Schedule
77 // close callback once when all data has been read. Only schedule 77 // close callback once when all data has been read. Only schedule
78 // a new callback if the previous one has actually been called. 78 // a new callback if the previous one has actually been called.
79 if (!_closeCallbackCalled) { 79 if (!_closeCallbackCalled) {
80 if (available() > 0) { 80 if (available() > 0) {
81 if (_scheduledDataCallback == null) { 81 if (_scheduledDataCallback == null) {
82 _scheduledDataCallback = new Timer(issueDataCallback, 0); 82 _scheduledDataCallback = new Timer(issueDataCallback, 0);
83 } 83 }
84 } else if (_streamMarkedClosed && !_closeCallbackCalled) { 84 } else if (_streamMarkedClosed && !_closeCallbackCalled) {
85 _close();
85 _scheduledCloseCallback = new Timer(issueCloseCallback, 0); 86 _scheduledCloseCallback = new Timer(issueCloseCallback, 0);
86 _closeCallbackCalled = true; 87 _closeCallbackCalled = true;
87 } 88 }
88 } 89 }
89 } 90 }
90 91
91 // When this is set to true the stream is marked closed. When a 92 // When this is set to true the stream is marked closed. When a
92 // stream is marked closed no more data can arrive and the value 93 // stream is marked closed no more data can arrive and the value
93 // from available is now all remaining data. If this is true and the 94 // from available is now all remaining data. If this is true and the
94 // value of available is zero the close handler is called. 95 // value of available is zero the close handler is called.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 input.dataHandler = pipeDataHandler; 133 input.dataHandler = pipeDataHandler;
133 output.noPendingWriteHandler = null; 134 output.noPendingWriteHandler = null;
134 }; 135 };
135 136
136 _inputCloseHandler = input._clientCloseHandler; 137 _inputCloseHandler = input._clientCloseHandler;
137 input.dataHandler = pipeDataHandler; 138 input.dataHandler = pipeDataHandler;
138 input.closeHandler = pipeCloseHandler; 139 input.closeHandler = pipeCloseHandler;
139 output.noPendingWriteHandler = null; 140 output.noPendingWriteHandler = null;
140 } 141 }
141 142
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698