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

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

Issue 9816005: Fix checked mode errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | no next file » | 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 5
6 class _SocketBase { 6 class _SocketBase {
7 // Bit flags used when communicating between the eventhandler and 7 // Bit flags used when communicating between the eventhandler and
8 // dart code. The EVENT flags are used to indicate events of 8 // dart code. The EVENT flags are used to indicate events of
9 // interest when sending a message from dart code to the 9 // interest when sending a message from dart code to the
10 // eventhandler. When receiving a message from the eventhandler the 10 // eventhandler. When receiving a message from the eventhandler the
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 assert(result); 261 assert(result);
262 if (port != 0) { 262 if (port != 0) {
263 socket._port = port; 263 socket._port = port;
264 } 264 }
265 return socket; 265 return socket;
266 } 266 }
267 267
268 _ServerSocket._internal(); 268 _ServerSocket._internal();
269 269
270 bool _accept(Socket socket) native "ServerSocket_Accept"; 270 _accept(Socket socket) native "ServerSocket_Accept";
271 271
272 bool _createBindListen(String bindAddress, int port, int backlog) 272 _createBindListen(String bindAddress, int port, int backlog)
273 native "ServerSocket_CreateBindListen"; 273 native "ServerSocket_CreateBindListen";
274 274
275 void set onConnection(void callback(Socket connection)) { 275 void set onConnection(void callback(Socket connection)) {
276 _clientConnectionHandler = callback; 276 _clientConnectionHandler = callback;
277 _setHandler(_IN_EVENT, 277 _setHandler(_IN_EVENT,
278 _clientConnectionHandler != null ? _connectionHandler : null); 278 _clientConnectionHandler != null ? _connectionHandler : null);
279 } 279 }
280 280
281 void _connectionHandler() { 281 void _connectionHandler() {
282 if (_id >= 0) { 282 if (_id >= 0) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 if (offset < 0) { 351 if (offset < 0) {
352 throw new IndexOutOfRangeException(offset); 352 throw new IndexOutOfRangeException(offset);
353 } 353 }
354 if (bytes < 0) { 354 if (bytes < 0) {
355 throw new IndexOutOfRangeException(bytes); 355 throw new IndexOutOfRangeException(bytes);
356 } 356 }
357 if ((offset + bytes) > buffer.length) { 357 if ((offset + bytes) > buffer.length) {
358 throw new IndexOutOfRangeException(offset + bytes); 358 throw new IndexOutOfRangeException(offset + bytes);
359 } 359 }
360 int result = _readList(buffer, offset, bytes); 360 var result = _readList(buffer, offset, bytes);
361 if (result is OSError) { 361 if (result is OSError) {
362 _reportError(result, "Read failed"); 362 _reportError(result, "Read failed");
363 return -1; 363 return -1;
364 } 364 }
365 return result; 365 return result;
366 } 366 }
367 throw new 367 throw new
368 SocketIOException("Error: readList failed - invalid socket handle"); 368 SocketIOException("Error: readList failed - invalid socket handle");
369 } 369 }
370 370
371 int _readList(List<int> buffer, int offset, int bytes) 371 _readList(List<int> buffer, int offset, int bytes)
372 native "Socket_ReadList"; 372 native "Socket_ReadList";
373 373
374 int writeList(List<int> buffer, int offset, int bytes) { 374 int writeList(List<int> buffer, int offset, int bytes) {
375 if (_id >= 0) { 375 if (_id >= 0) {
376 if (bytes == 0) { 376 if (bytes == 0) {
377 return 0; 377 return 0;
378 } 378 }
379 if (offset < 0) { 379 if (offset < 0) {
380 throw new IndexOutOfRangeException(offset); 380 throw new IndexOutOfRangeException(offset);
381 } 381 }
(...skipping 29 matching lines...) Expand all
411 // If writing fails we return 0 as the number of bytes and 411 // If writing fails we return 0 as the number of bytes and
412 // report the error on the error handler. 412 // report the error on the error handler.
413 result = 0; 413 result = 0;
414 _reportError(result, "Write failed"); 414 _reportError(result, "Write failed");
415 } 415 }
416 return result; 416 return result;
417 } 417 }
418 throw new SocketIOException("writeList failed - invalid socket handle"); 418 throw new SocketIOException("writeList failed - invalid socket handle");
419 } 419 }
420 420
421 int _writeList(List<int> buffer, int offset, int bytes) 421 _writeList(List<int> buffer, int offset, int bytes)
422 native "Socket_WriteList"; 422 native "Socket_WriteList";
423 423
424 bool _isErrorResponse(response) { 424 bool _isErrorResponse(response) {
425 return response is List && response[0] != _FileUtils.kSuccessResponse; 425 return response is List && response[0] != _FileUtils.kSuccessResponse;
426 } 426 }
427 427
428 bool _createConnect(String host, int port) native "Socket_CreateConnect"; 428 bool _createConnect(String host, int port) native "Socket_CreateConnect";
429 429
430 void set onWrite(void callback()) { 430 void set onWrite(void callback()) {
431 if (_outputStream != null) throw new StreamException( 431 if (_outputStream != null) throw new StreamException(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 537 }
538 538
539 bool _seenFirstOutEvent = false; 539 bool _seenFirstOutEvent = false;
540 bool _pipe = false; 540 bool _pipe = false;
541 Function _clientConnectHandler; 541 Function _clientConnectHandler;
542 Function _clientWriteHandler; 542 Function _clientWriteHandler;
543 SocketInputStream _inputStream; 543 SocketInputStream _inputStream;
544 SocketOutputStream _outputStream; 544 SocketOutputStream _outputStream;
545 static SendPort _socketService; 545 static SendPort _socketService;
546 } 546 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698