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

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

Issue 10905214: Fix two issues in the websocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months 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
« no previous file with comments | « no previous file | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 _socket._onWrite = _onWrite; 172 _socket._onWrite = _onWrite;
173 return false; 173 return false;
174 } 174 }
175 175
176 void _onWrite() { 176 void _onWrite() {
177 // Write as much buffered data to the socket as possible. 177 // Write as much buffered data to the socket as possible.
178 while (!_pendingWrites.isEmpty()) { 178 while (!_pendingWrites.isEmpty()) {
179 List<int> buffer = _pendingWrites.first; 179 List<int> buffer = _pendingWrites.first;
180 int offset = _pendingWrites.index; 180 int offset = _pendingWrites.index;
181 int bytesToWrite = buffer.length - offset; 181 int bytesToWrite = buffer.length - offset;
182 int bytesWritten = _socket.writeList(buffer, offset, bytesToWrite); 182 int bytesWritten;
183 try {
184 bytesWritten = _socket.writeList(buffer, offset, bytesToWrite);
185 } catch (e) {
186 _pendingWrites.clear();
187 _onSocketError(e);
188 return;
189 }
183 _pendingWrites.removeBytes(bytesWritten); 190 _pendingWrites.removeBytes(bytesWritten);
184 if (bytesWritten < bytesToWrite) { 191 if (bytesWritten < bytesToWrite) {
185 _socket._onWrite = _onWrite; 192 _socket._onWrite = _onWrite;
186 return; 193 return;
187 } 194 }
188 } 195 }
189 196
190 // All buffered data was written. 197 // All buffered data was written.
191 if (_closing) { 198 if (_closing) {
192 _socket._closeWrite(); 199 _socket._closeWrite();
(...skipping 21 matching lines...) Expand all
214 } 221 }
215 } 222 }
216 223
217 Socket _socket; 224 Socket _socket;
218 _BufferList _pendingWrites; 225 _BufferList _pendingWrites;
219 Function _onNoPendingWrites; 226 Function _onNoPendingWrites;
220 Function _onClosed; 227 Function _onClosed;
221 bool _closing = false; 228 bool _closing = false;
222 bool _closed = false; 229 bool _closed = false;
223 } 230 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698