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

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

Issue 8885032: Improve the event handling for string input stream (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
« no previous file with comments | « no previous file | runtime/bin/string_stream.dart » ('j') | runtime/bin/string_stream.dart » ('J')
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 _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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void set closeHandler(void callback()) { 47 void set closeHandler(void callback()) {
48 _clientCloseHandler = callback; 48 _clientCloseHandler = callback;
49 } 49 }
50 50
51 void _dataHandler() { 51 void _dataHandler() {
52 _readData(); 52 _readData();
53 if (_bufferList.length >= _chunkSize && _clientDataHandler !== null) { 53 if (_bufferList.length >= _chunkSize && _clientDataHandler !== null) {
54 _clientDataHandler(); 54 _clientDataHandler();
55 } 55 }
56 _checkScheduleCallback(); 56 _checkScheduleCallback();
57 _checkInstallDataHandler();
57 } 58 }
58 59
59 void _readData() { 60 void _readData() {
60 List<int> data = _input.read(); 61 List<int> data = _input.read();
61 if (data !== null) { 62 if (data !== null) {
62 _bufferList.add(data); 63 _bufferList.add(data);
63 } 64 }
64 } 65 }
65 66
66 void _closeHandler() { 67 void _closeHandler() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 InputStream _input; 125 InputStream _input;
125 _BufferList _bufferList; 126 _BufferList _bufferList;
126 int _chunkSize; 127 int _chunkSize;
127 bool _inputClosed = false; // Is the underlying input stream closed? 128 bool _inputClosed = false; // Is the underlying input stream closed?
128 bool _closed = false; // Has the close handler been called?. 129 bool _closed = false; // Has the close handler been called?.
129 Timer _scheduledDataCallback; 130 Timer _scheduledDataCallback;
130 Timer _scheduledCloseCallback; 131 Timer _scheduledCloseCallback;
131 Function _clientDataHandler; 132 Function _clientDataHandler;
132 Function _clientCloseHandler; 133 Function _clientCloseHandler;
133 } 134 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/string_stream.dart » ('j') | runtime/bin/string_stream.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698