| 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 17 matching lines...) Expand all Loading... |
| 28 return null; | 28 return null; |
| 29 } else if (bytesRead < bytesToRead) { | 29 } else if (bytesRead < bytesToRead) { |
| 30 ByteArray newBuffer = new ByteArray(bytesRead); | 30 ByteArray newBuffer = new ByteArray(bytesRead); |
| 31 newBuffer.setRange(0, bytesRead, buffer); | 31 newBuffer.setRange(0, bytesRead, buffer); |
| 32 return newBuffer; | 32 return newBuffer; |
| 33 } else { | 33 } else { |
| 34 return buffer; | 34 return buffer; |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 int readInto(List<int> buffer, int offset, int len) { | 38 int readInto(List<int> buffer, [int offset = 0, int len]) { |
| 39 if (offset === null) offset = 0; | 39 if (_closed) return null; |
| 40 if (len === null) len = buffer.length; | 40 if (len === null) len = buffer.length; |
| 41 if (offset < 0) throw new StreamException("Illegal offset $offset"); | 41 if (offset < 0) throw new StreamException("Illegal offset $offset"); |
| 42 if (len < 0) throw new StreamException("Illegal length $len"); | 42 if (len < 0) throw new StreamException("Illegal length $len"); |
| 43 return _socket.readList(buffer, offset, len); | 43 return _socket.readList(buffer, offset, len); |
| 44 } | 44 } |
| 45 | 45 |
| 46 int available() => _socket.available(); | 46 int available() => _socket.available(); |
| 47 | 47 |
| 48 void pipe(OutputStream output, [bool close = true]) { | 48 void pipe(OutputStream output, [bool close = true]) { |
| 49 _pipe(this, output, close: close); | 49 _pipe(this, output, close: close); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (_streamErrorHandler != null) _streamErrorHandler(); | 184 if (_streamErrorHandler != null) _streamErrorHandler(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 Socket _socket; | 187 Socket _socket; |
| 188 _BufferList _pendingWrites; | 188 _BufferList _pendingWrites; |
| 189 var _onNoPendingWrites; | 189 var _onNoPendingWrites; |
| 190 var _streamErrorHandler; | 190 var _streamErrorHandler; |
| 191 bool _closing = false; | 191 bool _closing = false; |
| 192 bool _closed = false; | 192 bool _closed = false; |
| 193 } | 193 } |
| OLD | NEW |