| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 ListInputStream extends _BaseDataInputStream implements InputStream { | 5 class ListInputStream extends _BaseDataInputStream implements InputStream { |
| 6 ListInputStream(List<int> this._buffer) { | 6 ListInputStream(List<int> this._buffer) { |
| 7 _streamMarkedClosed = true; | 7 _streamMarkedClosed = true; |
| 8 } | 8 } |
| 9 | 9 |
| 10 int available() => _buffer.length - _offset; | 10 int available() => _buffer.length - _offset; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 class ListOutputStream implements OutputStream { | 64 class ListOutputStream implements OutputStream { |
| 65 ListOutputStream() : _bufferList = new _BufferList(); | 65 ListOutputStream() : _bufferList = new _BufferList(); |
| 66 | 66 |
| 67 bool write(List<int> buffer, [bool copyBuffer = false]) { | 67 bool write(List<int> buffer, [bool copyBuffer = false]) { |
| 68 if (_streamMarkedClosed) throw new StreamException.streamClosed(); | 68 if (_streamMarkedClosed) throw new StreamException.streamClosed(); |
| 69 if (copyBuffer) { | 69 if (copyBuffer) { |
| 70 _bufferList.add(buffer.getRange(0, buffer.length)); | 70 _bufferList.add(buffer.getRange(0, buffer.length)); |
| 71 } else { | 71 } else { |
| 72 _bufferList.add(buffer); | 72 _bufferList.add(buffer); |
| 73 } | 73 } |
| 74 return true; |
| 74 } | 75 } |
| 75 | 76 |
| 76 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { | 77 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { |
| 77 if (_streamMarkedClosed) throw new StreamException.streamClosed(); | 78 if (_streamMarkedClosed) throw new StreamException.streamClosed(); |
| 78 _bufferList.add( | 79 _bufferList.add( |
| 79 buffer.getRange(offset, (len == null) ? buffer.length - offset : len)); | 80 buffer.getRange(offset, (len == null) ? buffer.length - offset : len)); |
| 81 return true; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void close() { | 84 void close() { |
| 83 if (_streamMarkedClosed) throw new StreamException.streamClosed(); | 85 if (_streamMarkedClosed) throw new StreamException.streamClosed(); |
| 84 _streamMarkedClosed = true; | 86 _streamMarkedClosed = true; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void destroy() { | 89 void destroy() { |
| 88 close(); | 90 close(); |
| 89 } | 91 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 140 } |
| 139 | 141 |
| 140 _BufferList _bufferList; | 142 _BufferList _bufferList; |
| 141 bool _streamMarkedClosed = false; | 143 bool _streamMarkedClosed = false; |
| 142 bool _closeCallbackCalled = false; | 144 bool _closeCallbackCalled = false; |
| 143 Timer _scheduledNoPendingWriteCallback; | 145 Timer _scheduledNoPendingWriteCallback; |
| 144 Timer _scheduledCloseCallback; | 146 Timer _scheduledCloseCallback; |
| 145 Function _clientNoPendingWriteHandler; | 147 Function _clientNoPendingWriteHandler; |
| 146 Function _clientCloseHandler; | 148 Function _clientCloseHandler; |
| 147 } | 149 } |
| OLD | NEW |