Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: runtime/bin/socket_stream.dart

Issue 8662006: Fix a number of issues with the process handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 SocketInputStream implements InputStream { 5 class SocketInputStream implements InputStream {
6 SocketInputStream(Socket socket) : _socket = socket; 6 SocketInputStream(Socket socket) : _socket = socket;
7 7
8 List<int> read([int len]) { 8 List<int> read([int len]) {
9 int bytesToRead = available(); 9 int bytesToRead = available();
10 if (bytesToRead == 0) return null; 10 if (bytesToRead == 0) return null;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 int notWrittenOffset = offset + bytesWritten; 118 int notWrittenOffset = offset + bytesWritten;
119 if (copyBuffer) { 119 if (copyBuffer) {
120 List<int> newBuffer = 120 List<int> newBuffer =
121 buffer.getRange(notWrittenOffset, len - bytesWritten); 121 buffer.getRange(notWrittenOffset, len - bytesWritten);
122 _pendingWrites.add(newBuffer); 122 _pendingWrites.add(newBuffer);
123 } else { 123 } else {
124 assert(offset + len == buffer.length); 124 assert(offset + len == buffer.length);
125 _pendingWrites.add(buffer, notWrittenOffset); 125 _pendingWrites.add(buffer, notWrittenOffset);
126 } 126 }
127 _socket.writeHandler = _writeHandler; 127 _socket.writeHandler = _writeHandler;
128 return false;
128 } 129 }
129 130
130 void _writeHandler() { 131 void _writeHandler() {
131 // Write as much buffered data to the socket as possible. 132 // Write as much buffered data to the socket as possible.
132 while (!_pendingWrites.isEmpty()) { 133 while (!_pendingWrites.isEmpty()) {
133 List<int> buffer = _pendingWrites.first; 134 List<int> buffer = _pendingWrites.first;
134 int offset = _pendingWrites.index; 135 int offset = _pendingWrites.index;
135 int bytesToWrite = buffer.length - offset; 136 int bytesToWrite = buffer.length - offset;
136 int bytesWritten = _socket.writeList(buffer, offset, bytesToWrite); 137 int bytesWritten = _socket.writeList(buffer, offset, bytesToWrite);
137 _pendingWrites.removeBytes(bytesWritten); 138 _pendingWrites.removeBytes(bytesWritten);
(...skipping 18 matching lines...) Expand all
156 if (_streamErrorHandler != null) _streamErrorHandler(); 157 if (_streamErrorHandler != null) _streamErrorHandler();
157 } 158 }
158 159
159 Socket _socket; 160 Socket _socket;
160 _BufferList _pendingWrites; 161 _BufferList _pendingWrites;
161 var _noPendingWriteHandler; 162 var _noPendingWriteHandler;
162 var _streamErrorHandler; 163 var _streamErrorHandler;
163 bool _closing = false; 164 bool _closing = false;
164 bool _closed = false; 165 bool _closed = false;
165 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698