| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 void set onClosed(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 onError(void callback(e)) { | 56 void set onError(void callback(e)) { |
| 57 _clientErrorHandler = callback; | 57 _clientErrorHandler = callback; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void _reportError(e) { |
| 61 if (_clientErrorHandler != null) { |
| 62 _clientErrorHandler(e); |
| 63 } else { |
| 64 throw e; |
| 65 } |
| 66 } |
| 67 |
| 60 abstract List<int> _read(int bytesToRead); | 68 abstract List<int> _read(int bytesToRead); |
| 61 | 69 |
| 62 void _dataReceived() { | 70 void _dataReceived() { |
| 63 // More data has been received asynchronously. Perform the data | 71 // More data has been received asynchronously. Perform the data |
| 64 // handler callback now. | 72 // handler callback now. |
| 65 _cancelScheduledDataCallback(); | 73 _cancelScheduledDataCallback(); |
| 66 if (_clientDataHandler !== null) { | 74 if (_clientDataHandler !== null) { |
| 67 _clientDataHandler(); | 75 _clientDataHandler(); |
| 68 } | 76 } |
| 69 _checkScheduleCallbacks(); | 77 _checkScheduleCallbacks(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 void _reportError(e) { | 202 void _reportError(e) { |
| 195 if (_onError != null) { | 203 if (_onError != null) { |
| 196 _onError(e); | 204 _onError(e); |
| 197 } else { | 205 } else { |
| 198 throw e; | 206 throw e; |
| 199 } | 207 } |
| 200 } | 208 } |
| 201 | 209 |
| 202 Function _onError; | 210 Function _onError; |
| 203 } | 211 } |
| OLD | NEW |