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

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

Issue 8992007: Make the repeating argument to timers optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
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 _ChunkedInputStream implements ChunkedInputStream { 5 class _ChunkedInputStream implements ChunkedInputStream {
6 _ChunkedInputStream(InputStream this._input, [int chunkSize]) 6 _ChunkedInputStream(InputStream this._input, [int chunkSize])
7 : _chunkSize = chunkSize, _bufferList = new _BufferList() { 7 : _chunkSize = chunkSize, _bufferList = new _BufferList() {
8 if (_chunkSize === null) { 8 if (_chunkSize === null) {
9 _chunkSize = 0; 9 _chunkSize = 0;
10 } 10 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (_clientCloseHandler !== null) _clientCloseHandler(); 103 if (_clientCloseHandler !== null) _clientCloseHandler();
104 _closed = true; 104 _closed = true;
105 } 105 }
106 } 106 }
107 107
108 // Schedule data callback if enough data in buffer. 108 // Schedule data callback if enough data in buffer.
109 if ((_bufferList.length >=_chunkSize || 109 if ((_bufferList.length >=_chunkSize ||
110 (_bufferList.length > 0 && _inputClosed)) && 110 (_bufferList.length > 0 && _inputClosed)) &&
111 _clientDataHandler !== null && 111 _clientDataHandler !== null &&
112 _scheduledDataCallback == null) { 112 _scheduledDataCallback == null) {
113 _scheduledDataCallback = new Timer(issueDataCallback, 0, false); 113 _scheduledDataCallback = new Timer(issueDataCallback, 0);
114 } 114 }
115 115
116 // Schedule close callback if no more data and input is closed. 116 // Schedule close callback if no more data and input is closed.
117 if (_bufferList.length == 0 && 117 if (_bufferList.length == 0 &&
118 _inputClosed && 118 _inputClosed &&
119 !_closed && 119 !_closed &&
120 _scheduledCloseCallback == null) { 120 _scheduledCloseCallback == null) {
121 _scheduledCloseCallback = new Timer(issueCloseCallback, 0, false); 121 _scheduledCloseCallback = new Timer(issueCloseCallback, 0);
122 } 122 }
123 } 123 }
124 124
125 InputStream _input; 125 InputStream _input;
126 _BufferList _bufferList; 126 _BufferList _bufferList;
127 int _chunkSize; 127 int _chunkSize;
128 bool _inputClosed = false; // Is the underlying input stream closed? 128 bool _inputClosed = false; // Is the underlying input stream closed?
129 bool _closed = false; // Has the close handler been called?. 129 bool _closed = false; // Has the close handler been called?.
130 Timer _scheduledDataCallback; 130 Timer _scheduledDataCallback;
131 Timer _scheduledCloseCallback; 131 Timer _scheduledCloseCallback;
132 Function _clientDataHandler; 132 Function _clientDataHandler;
133 Function _clientCloseHandler; 133 Function _clientCloseHandler;
134 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698