| 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 _SocketInputStream implements SocketInputStream { | 5 class _SocketInputStream implements SocketInputStream { |
| 6 _SocketInputStream(Socket socket) : _socket = socket { | 6 _SocketInputStream(Socket socket) : _socket = socket { |
| 7 if (_socket._id == -1) _closed = true; | 7 if (_socket._id == -1) _closed = true; |
| 8 _socket.onClosed = _onClosed; | 8 _socket.onClosed = _onClosed; |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 // All buffered data was written. | 170 // All buffered data was written. |
| 171 if (_closing) { | 171 if (_closing) { |
| 172 _socket._closeWrite(); | 172 _socket._closeWrite(); |
| 173 _closed = true; | 173 _closed = true; |
| 174 } else { | 174 } else { |
| 175 if (_onNoPendingWrites != null) _onNoPendingWrites(); | 175 if (_onNoPendingWrites != null) _onNoPendingWrites(); |
| 176 } | 176 } |
| 177 if (_onNoPendingWrites == null) _socket._onWrite = null; | 177 if (_onNoPendingWrites == null) { |
| 178 _socket._onWrite = null; |
| 179 } else { |
| 180 _socket._onWrite = _onWrite; |
| 181 } |
| 178 } | 182 } |
| 179 | 183 |
| 180 void set onError(void callback(Exception e)) { | 184 void set onError(void callback(Exception e)) { |
| 181 _errorCallback = callback; | 185 _errorCallback = callback; |
| 182 } | 186 } |
| 183 | 187 |
| 184 void _onError(Exception e) { | 188 void _onError(Exception e) { |
| 185 close(); | 189 close(); |
| 186 if (_errorCallback != null) _errorCallback(e); | 190 if (_errorCallback != null) _errorCallback(e); |
| 187 } | 191 } |
| 188 | 192 |
| 189 Socket _socket; | 193 Socket _socket; |
| 190 _BufferList _pendingWrites; | 194 _BufferList _pendingWrites; |
| 191 var _onNoPendingWrites; | 195 var _onNoPendingWrites; |
| 192 Function _errorCallback; | 196 Function _errorCallback; |
| 193 bool _closing = false; | 197 bool _closing = false; |
| 194 bool _closed = false; | 198 bool _closed = false; |
| 195 } | 199 } |
| OLD | NEW |