| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 void close() { | 38 void close() { |
| 39 _cancelScheduledDataCallback(); | 39 _cancelScheduledDataCallback(); |
| 40 _close(); | 40 _close(); |
| 41 _checkScheduleCallbacks(); | 41 _checkScheduleCallbacks(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool get closed() => _closeCallbackCalled; | 44 bool get closed() => _closeCallbackCalled; |
| 45 | 45 |
| 46 void set dataHandler(void callback()) { | 46 void set onData(void callback()) { |
| 47 _clientDataHandler = callback; | 47 _clientDataHandler = callback; |
| 48 _checkScheduleCallbacks(); | 48 _checkScheduleCallbacks(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void set closeHandler(void callback()) { | 51 void set onClosed(void callback()) { |
| 52 _clientCloseHandler = callback; | 52 _clientCloseHandler = callback; |
| 53 _checkScheduleCallbacks(); | 53 _checkScheduleCallbacks(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void set errorHandler(void callback()) { | 56 void set onError(void callback()) { |
| 57 _clientErrorHandler = callback; | 57 _clientErrorHandler = callback; |
| 58 } | 58 } |
| 59 | 59 |
| 60 abstract List<int> _read(int bytesToRead); | 60 abstract List<int> _read(int bytesToRead); |
| 61 | 61 |
| 62 void _dataReceived() { | 62 void _dataReceived() { |
| 63 // More data has been received asynchronously. Perform the data | 63 // More data has been received asynchronously. Perform the data |
| 64 // handler callback now. | 64 // handler callback now. |
| 65 _cancelScheduledDataCallback(); | 65 _cancelScheduledDataCallback(); |
| 66 if (_clientDataHandler !== null) { | 66 if (_clientDataHandler !== null) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 Function pipeDataHandler; | 143 Function pipeDataHandler; |
| 144 Function pipeCloseHandler; | 144 Function pipeCloseHandler; |
| 145 Function pipeNoPendingWriteHandler; | 145 Function pipeNoPendingWriteHandler; |
| 146 | 146 |
| 147 Function _inputCloseHandler; | 147 Function _inputCloseHandler; |
| 148 | 148 |
| 149 pipeDataHandler = () { | 149 pipeDataHandler = () { |
| 150 List<int> data; | 150 List<int> data; |
| 151 while ((data = input.read()) !== null) { | 151 while ((data = input.read()) !== null) { |
| 152 if (!output.write(data)) { | 152 if (!output.write(data)) { |
| 153 input.dataHandler = null; | 153 input.onData = null; |
| 154 output.noPendingWriteHandler = pipeNoPendingWriteHandler; | 154 output.onNoPendingWrites = pipeNoPendingWriteHandler; |
| 155 break; | 155 break; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 pipeCloseHandler = () { | 160 pipeCloseHandler = () { |
| 161 if (close) output.close(); | 161 if (close) output.close(); |
| 162 if (_inputCloseHandler !== null) { | 162 if (_inputCloseHandler !== null) { |
| 163 _inputCloseHandler(); | 163 _inputCloseHandler(); |
| 164 } | 164 } |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 pipeNoPendingWriteHandler = () { | 167 pipeNoPendingWriteHandler = () { |
| 168 input.dataHandler = pipeDataHandler; | 168 input.onData = pipeDataHandler; |
| 169 output.noPendingWriteHandler = null; | 169 output.onNoPendingWrites = null; |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 _inputCloseHandler = input._clientCloseHandler; | 172 _inputCloseHandler = input._clientCloseHandler; |
| 173 input.dataHandler = pipeDataHandler; | 173 input.onData = pipeDataHandler; |
| 174 input.closeHandler = pipeCloseHandler; | 174 input.onClosed = pipeCloseHandler; |
| 175 output.noPendingWriteHandler = null; | 175 output.onNoPendingWrites = null; |
| 176 } | 176 } |
| 177 | 177 |
| OLD | NEW |