| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |