| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 bool write(List<int> buffer, [bool copyBuffer = true]) { | 102 bool write(List<int> buffer, [bool copyBuffer = true]) { |
| 103 return _write(buffer, 0, buffer.length, copyBuffer); | 103 return _write(buffer, 0, buffer.length, copyBuffer); |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { | 106 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { |
| 107 return _write( | 107 return _write( |
| 108 buffer, offset, (len == null) ? buffer.length - offset : len, true); | 108 buffer, offset, (len == null) ? buffer.length - offset : len, true); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void flush() { |
| 112 // Nothing to do on a socket output stream. |
| 113 } |
| 114 |
| 111 void close() { | 115 void close() { |
| 112 if (_closing && _closed) return; | 116 if (_closing && _closed) return; |
| 113 if (!_pendingWrites.isEmpty()) { | 117 if (!_pendingWrites.isEmpty()) { |
| 114 // Mark the socket for close when all data is written. | 118 // Mark the socket for close when all data is written. |
| 115 _closing = true; | 119 _closing = true; |
| 116 _socket._onWrite = _onWrite; | 120 _socket._onWrite = _onWrite; |
| 117 } else { | 121 } else { |
| 118 // Close the socket for writing. | 122 // Close the socket for writing. |
| 119 _socket._closeWrite(); | 123 _socket._closeWrite(); |
| 120 _closed = true; | 124 _closed = true; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 212 } |
| 209 } | 213 } |
| 210 | 214 |
| 211 Socket _socket; | 215 Socket _socket; |
| 212 _BufferList _pendingWrites; | 216 _BufferList _pendingWrites; |
| 213 Function _onNoPendingWrites; | 217 Function _onNoPendingWrites; |
| 214 Function _onClosed; | 218 Function _onClosed; |
| 215 bool _closing = false; | 219 bool _closing = false; |
| 216 bool _closed = false; | 220 bool _closed = false; |
| 217 } | 221 } |
| OLD | NEW |