| 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 // Interface for decoders decoding binary data into string data. The | 5 // Interface for decoders decoding binary data into string data. The |
| 6 // decoder keeps track of line breaks during decoding. | 6 // decoder keeps track of line breaks during decoding. |
| 7 interface _StringDecoder { | 7 interface _StringDecoder { |
| 8 // Add more binary data to be decoded. The ownership of the buffer | 8 // Add more binary data to be decoded. The ownership of the buffer |
| 9 // is transfered to the decoder and the caller most not modify it any more. | 9 // is transfered to the decoder and the caller most not modify it any more. |
| 10 int write(List<int> buffer); | 10 int write(List<int> buffer); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 _clientLineHandler = callback; | 268 _clientLineHandler = callback; |
| 269 _clientDataHandler = null; | 269 _clientDataHandler = null; |
| 270 _checkInstallDataHandler(); | 270 _checkInstallDataHandler(); |
| 271 _checkScheduleCallback(); | 271 _checkScheduleCallback(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void set closeHandler(void callback()) { | 274 void set closeHandler(void callback()) { |
| 275 _clientCloseHandler = callback; | 275 _clientCloseHandler = callback; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void set errorHandler(void callback()) { |
| 279 _input.errorHandler = callback; |
| 280 } |
| 281 |
| 278 void _dataHandler() { | 282 void _dataHandler() { |
| 279 _readData(); | 283 _readData(); |
| 280 if (!_decoder.isEmpty() && _clientDataHandler !== null) { | 284 if (!_decoder.isEmpty() && _clientDataHandler !== null) { |
| 281 _clientDataHandler(); | 285 _clientDataHandler(); |
| 282 } | 286 } |
| 283 if (_decoder.lineBreaks > 0 && _clientLineHandler !== null) { | 287 if (_decoder.lineBreaks > 0 && _clientLineHandler !== null) { |
| 284 _clientLineHandler(); | 288 _clientLineHandler(); |
| 285 } | 289 } |
| 286 _checkScheduleCallback(); | 290 _checkScheduleCallback(); |
| 287 _checkInstallDataHandler(); | 291 _checkInstallDataHandler(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 bool _inputClosed = false; // Is the underlying input stream closed? | 387 bool _inputClosed = false; // Is the underlying input stream closed? |
| 384 bool _closed = false; // Is this stream closed. | 388 bool _closed = false; // Is this stream closed. |
| 385 bool _eof = false; // Has all data been read from the decoder? | 389 bool _eof = false; // Has all data been read from the decoder? |
| 386 Timer _scheduledDataCallback; | 390 Timer _scheduledDataCallback; |
| 387 Timer _scheduledLineCallback; | 391 Timer _scheduledLineCallback; |
| 388 Timer _scheduledCloseCallback; | 392 Timer _scheduledCloseCallback; |
| 389 Function _clientDataHandler; | 393 Function _clientDataHandler; |
| 390 Function _clientLineHandler; | 394 Function _clientLineHandler; |
| 391 Function _clientCloseHandler; | 395 Function _clientCloseHandler; |
| 392 } | 396 } |
| OLD | NEW |