Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 } | 302 } |
| 303 if (bytes < 0) { | 303 if (bytes < 0) { |
| 304 throw new IndexOutOfRangeException(bytes); | 304 throw new IndexOutOfRangeException(bytes); |
| 305 } | 305 } |
| 306 if ((offset + bytes) > buffer.length) { | 306 if ((offset + bytes) > buffer.length) { |
| 307 throw new IndexOutOfRangeException(offset + bytes); | 307 throw new IndexOutOfRangeException(offset + bytes); |
| 308 } | 308 } |
| 309 // When using the Dart C API access to ObjectArray by index is | 309 // When using the Dart C API access to ObjectArray by index is |
| 310 // currently much faster. This function will make a copy of the | 310 // currently much faster. This function will make a copy of the |
| 311 // supplied List to an ObjectArray if it isn't already. | 311 // supplied List to an ObjectArray if it isn't already. |
| 312 ObjectArray outBuffer; | 312 List<int> outBuffer; |
|
cshapiro
2012/01/27 23:00:04
I think this can safely be retyped as a ByteArray
Anders Johnsen
2012/01/27 23:42:39
The thing is, that both a ByteArray and an ObjectA
| |
| 313 int outOffset = offset; | 313 int outOffset = offset; |
| 314 if (buffer is ObjectArray) { | 314 if (buffer is ObjectArray) { |
| 315 outBuffer = buffer; | 315 outBuffer = buffer; |
| 316 } else if (buffer is ByteArray) { | |
| 317 outBuffer = buffer; | |
| 316 } else { | 318 } else { |
| 317 outBuffer = new ObjectArray(bytes); | 319 outBuffer = new ByteArray(bytes); |
| 318 outOffset = 0; | 320 outOffset = 0; |
| 319 int j = offset; | 321 int j = offset; |
| 320 for (int i = 0; i < bytes; i++) { | 322 for (int i = 0; i < bytes; i++) { |
| 321 outBuffer[i] = buffer[j]; | 323 outBuffer[i] = buffer[j]; |
| 322 j++; | 324 j++; |
| 323 } | 325 } |
| 324 } | 326 } |
| 325 var bytes_written = _writeList(outBuffer, outOffset, bytes); | 327 var bytes_written = _writeList(outBuffer, outOffset, bytes); |
| 326 if (bytes_written < 0) { | 328 if (bytes_written < 0) { |
| 327 // If writing fails we return 0 as the number of bytes and | 329 // If writing fails we return 0 as the number of bytes and |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 bool _seenFirstOutEvent = false; | 457 bool _seenFirstOutEvent = false; |
| 456 bool _closedRead = false; | 458 bool _closedRead = false; |
| 457 bool _closedWrite = false; | 459 bool _closedWrite = false; |
| 458 bool _pipe = false; | 460 bool _pipe = false; |
| 459 Function _clientConnectHandler; | 461 Function _clientConnectHandler; |
| 460 Function _clientWriteHandler; | 462 Function _clientWriteHandler; |
| 461 SocketInputStream _inputStream; | 463 SocketInputStream _inputStream; |
| 462 SocketOutputStream _outputStream; | 464 SocketOutputStream _outputStream; |
| 463 } | 465 } |
| 464 | 466 |
| OLD | NEW |