| 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 || _scheduledCloseCallback != null) return null; | 9 if (_closeCallbackCalled || _scheduledCloseCallback != null) return null; |
| 10 int bytesToRead = available(); | 10 int bytesToRead = available(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 _clientDataHandler(); | 75 _clientDataHandler(); |
| 76 } | 76 } |
| 77 _checkScheduleCallbacks(); | 77 _checkScheduleCallbacks(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void _closeReceived() { | 80 void _closeReceived() { |
| 81 // Close indication has been received asynchronously. Perform the | 81 // Close indication has been received asynchronously. Perform the |
| 82 // close callback now if all data has been delivered. | 82 // close callback now if all data has been delivered. |
| 83 _streamMarkedClosed = true; | 83 _streamMarkedClosed = true; |
| 84 if (available() == 0) { | 84 if (available() == 0) { |
| 85 if (_clientCloseHandler !== null) { | 85 _closeCallbackCalled = true; |
| 86 _clientCloseHandler(); | 86 if (_clientCloseHandler !== null) _clientCloseHandler(); |
| 87 _closeCallbackCalled = true; | |
| 88 } | |
| 89 } else { | 87 } else { |
| 90 _checkScheduleCallbacks(); | 88 _checkScheduleCallbacks(); |
| 91 } | 89 } |
| 92 } | 90 } |
| 93 | 91 |
| 94 void _cancelScheduledDataCallback() { | 92 void _cancelScheduledDataCallback() { |
| 95 if (_scheduledDataCallback != null) { | 93 if (_scheduledDataCallback != null) { |
| 96 _scheduledDataCallback.cancel(); | 94 _scheduledDataCallback.cancel(); |
| 97 _scheduledDataCallback = null; | 95 _scheduledDataCallback = null; |
| 98 } | 96 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void _reportError(e) { | 200 void _reportError(e) { |
| 203 if (_onError != null) { | 201 if (_onError != null) { |
| 204 _onError(e); | 202 _onError(e); |
| 205 } else { | 203 } else { |
| 206 throw e; | 204 throw e; |
| 207 } | 205 } |
| 208 } | 206 } |
| 209 | 207 |
| 210 Function _onError; | 208 Function _onError; |
| 211 } | 209 } |
| OLD | NEW |