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

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

Issue 9597015: Update Timer API to take the callback as the last parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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/process_impl.dart ('k') | runtime/bin/string_stream.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) 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 _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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 _scheduledCloseCallback = null; 103 _scheduledCloseCallback = null;
104 if (_clientCloseHandler !== null) _clientCloseHandler(); 104 if (_clientCloseHandler !== null) _clientCloseHandler();
105 } 105 }
106 106
107 // Schedule data callback if there is more data to read. Schedule 107 // Schedule data callback if there is more data to read. Schedule
108 // close callback once when all data has been read. Only schedule 108 // close callback once when all data has been read. Only schedule
109 // a new callback if the previous one has actually been called. 109 // a new callback if the previous one has actually been called.
110 if (!_closeCallbackCalled) { 110 if (!_closeCallbackCalled) {
111 if (available() > 0) { 111 if (available() > 0) {
112 if (_scheduledDataCallback == null) { 112 if (_scheduledDataCallback == null) {
113 _scheduledDataCallback = new Timer(issueDataCallback, 0); 113 _scheduledDataCallback = new Timer(0, issueDataCallback);
114 } 114 }
115 } else if (_streamMarkedClosed && !_closeCallbackCalled) { 115 } else if (_streamMarkedClosed && !_closeCallbackCalled) {
116 _cancelScheduledDataCallback(); 116 _cancelScheduledDataCallback();
117 _close(); 117 _close();
118 _scheduledCloseCallback = new Timer(issueCloseCallback, 0); 118 _scheduledCloseCallback = new Timer(0, issueCloseCallback);
119 _closeCallbackCalled = true; 119 _closeCallbackCalled = true;
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 // When this is set to true the stream is marked closed. When a 124 // When this is set to true the stream is marked closed. When a
125 // stream is marked closed no more data can arrive and the value 125 // stream is marked closed no more data can arrive and the value
126 // from available is now all remaining data. If this is true and the 126 // from available is now all remaining data. If this is true and the
127 // value of available is zero the close handler is called. 127 // value of available is zero the close handler is called.
128 bool _streamMarkedClosed = false; 128 bool _streamMarkedClosed = false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 input.onData = pipeDataHandler; 168 input.onData = pipeDataHandler;
169 output.onNoPendingWrites = null; 169 output.onNoPendingWrites = null;
170 }; 170 };
171 171
172 _inputCloseHandler = input._clientCloseHandler; 172 _inputCloseHandler = input._clientCloseHandler;
173 input.onData = pipeDataHandler; 173 input.onData = pipeDataHandler;
174 input.onClosed = pipeCloseHandler; 174 input.onClosed = pipeCloseHandler;
175 output.onNoPendingWrites = null; 175 output.onNoPendingWrites = null;
176 } 176 }
177 177
OLDNEW
« no previous file with comments | « runtime/bin/process_impl.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698