Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, 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 |
| 11 // EVENT flags indicate the events that actually happened. The | 11 // EVENT flags indicate the events that actually happened. The |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 } | 315 } |
| 316 if (offset < 0) { | 316 if (offset < 0) { |
| 317 throw new IndexOutOfRangeException(offset); | 317 throw new IndexOutOfRangeException(offset); |
| 318 } | 318 } |
| 319 if (bytes < 0) { | 319 if (bytes < 0) { |
| 320 throw new IndexOutOfRangeException(bytes); | 320 throw new IndexOutOfRangeException(bytes); |
| 321 } | 321 } |
| 322 if ((offset + bytes) > buffer.length) { | 322 if ((offset + bytes) > buffer.length) { |
| 323 throw new IndexOutOfRangeException(offset + bytes); | 323 throw new IndexOutOfRangeException(offset + bytes); |
| 324 } | 324 } |
| 325 var bytes_written = _writeList(buffer, offset, bytes); | 325 ObjectArray outBuffer; |
| 326 int outOffset = offset; | |
| 327 if (buffer is ObjectArray) { | |
| 328 outBuffer = buffer; | |
| 329 } else { | |
| 330 // When using the Dart C API access to ObjectArray by index is | |
|
Mads Ager (google)
2012/01/19 08:38:25
Please move the comment to the same place as in th
Søren Gjesse
2012/01/19 08:45:14
Done.
| |
| 331 // currently much faster. This function will make a *copy* of | |
| 332 // the supplied List to an ObjectArray if it isn't already. | |
| 333 outBuffer = new ObjectArray(bytes); | |
| 334 outOffset = 0; | |
| 335 int j = offset; | |
| 336 for (int i = 0; i < bytes; i++) { | |
| 337 outBuffer[i] = buffer[j]; | |
| 338 j++; | |
| 339 } | |
| 340 } | |
| 341 var bytes_written = _writeList(outBuffer, outOffset, bytes); | |
| 326 if (bytes_written < 0) { | 342 if (bytes_written < 0) { |
| 327 // If writing fails we return 0 as the number of bytes and | 343 // If writing fails we return 0 as the number of bytes and |
| 328 // report the error on the error handler. | 344 // report the error on the error handler. |
| 329 bytes_written = 0; | 345 bytes_written = 0; |
| 330 _reportError(); | 346 _reportError(); |
| 331 } | 347 } |
| 332 return bytes_written; | 348 return bytes_written; |
| 333 } | 349 } |
| 334 throw new | 350 throw new |
| 335 SocketIOException("Error: writeList failed - invalid socket handle"); | 351 SocketIOException("Error: writeList failed - invalid socket handle"); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 bool _seenFirstOutEvent = false; | 471 bool _seenFirstOutEvent = false; |
| 456 bool _closedRead = false; | 472 bool _closedRead = false; |
| 457 bool _closedWrite = false; | 473 bool _closedWrite = false; |
| 458 bool _pipe = false; | 474 bool _pipe = false; |
| 459 Function _clientConnectHandler; | 475 Function _clientConnectHandler; |
| 460 Function _clientWriteHandler; | 476 Function _clientWriteHandler; |
| 461 SocketInputStream _inputStream; | 477 SocketInputStream _inputStream; |
| 462 SocketOutputStream _outputStream; | 478 SocketOutputStream _outputStream; |
| 463 } | 479 } |
| 464 | 480 |
| OLD | NEW |