| 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 _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 17 matching lines...) Expand all Loading... |
| 28 if (offset < 0) throw new StreamException("Illegal offset $offset"); | 28 if (offset < 0) throw new StreamException("Illegal offset $offset"); |
| 29 if (len < 0) throw new StreamException("Illegal length $len"); | 29 if (len < 0) throw new StreamException("Illegal length $len"); |
| 30 int bytesToRead = Math.min(len, available()); | 30 int bytesToRead = Math.min(len, available()); |
| 31 return _readInto(buffer, offset, bytesToRead); | 31 return _readInto(buffer, offset, bytesToRead); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void pipe(OutputStream output, [bool close = true]) { | 34 void pipe(OutputStream output, [bool close = true]) { |
| 35 _pipe(this, output, close: close); | 35 _pipe(this, output, close: close); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void close() { |
| 39 if (_scheduledDataCallback != null) _scheduledDataCallback.cancel(); |
| 40 _close(); |
| 41 _checkScheduleCallbacks(); |
| 42 } |
| 43 |
| 38 bool get closed() => _closeCallbackCalled; | 44 bool get closed() => _closeCallbackCalled; |
| 39 | 45 |
| 40 void set dataHandler(void callback()) { | 46 void set dataHandler(void callback()) { |
| 41 _clientDataHandler = callback; | 47 _clientDataHandler = callback; |
| 42 _checkScheduleCallbacks(); | 48 _checkScheduleCallbacks(); |
| 43 } | 49 } |
| 44 | 50 |
| 45 void set closeHandler(void callback()) { | 51 void set closeHandler(void callback()) { |
| 46 _clientCloseHandler = callback; | 52 _clientCloseHandler = callback; |
| 47 _checkScheduleCallbacks(); | 53 _checkScheduleCallbacks(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 input.dataHandler = pipeDataHandler; | 132 input.dataHandler = pipeDataHandler; |
| 127 output.noPendingWriteHandler = null; | 133 output.noPendingWriteHandler = null; |
| 128 }; | 134 }; |
| 129 | 135 |
| 130 _inputCloseHandler = input._clientCloseHandler; | 136 _inputCloseHandler = input._clientCloseHandler; |
| 131 input.dataHandler = pipeDataHandler; | 137 input.dataHandler = pipeDataHandler; |
| 132 input.closeHandler = pipeCloseHandler; | 138 input.closeHandler = pipeCloseHandler; |
| 133 output.noPendingWriteHandler = null; | 139 output.noPendingWriteHandler = null; |
| 134 } | 140 } |
| 135 | 141 |
| OLD | NEW |