| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "bin/io_buffer.h" | 5 #include "bin/io_buffer.h" |
| 6 #include "bin/socket.h" | 6 #include "bin/socket.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 intptr_t total_bytes_written = 0; | 181 intptr_t total_bytes_written = 0; |
| 182 intptr_t bytes_written = 0; | 182 intptr_t bytes_written = 0; |
| 183 if (Dart_IsByteArrayExternal(buffer_obj)) { | 183 if (Dart_IsByteArrayExternal(buffer_obj)) { |
| 184 void* buffer = NULL; | 184 void* buffer = NULL; |
| 185 result = Dart_ExternalByteArrayGetData(buffer_obj, &buffer); | 185 result = Dart_ExternalByteArrayGetData(buffer_obj, &buffer); |
| 186 if (Dart_IsError(result)) { | 186 if (Dart_IsError(result)) { |
| 187 Dart_PropagateError(result); | 187 Dart_PropagateError(result); |
| 188 } | 188 } |
| 189 buffer = static_cast<void*>((static_cast<uint8_t*>(buffer) + offset)); |
| 189 bytes_written = Socket::Write(socket, buffer, length); | 190 bytes_written = Socket::Write(socket, buffer, length); |
| 190 if (bytes_written > 0) total_bytes_written = bytes_written; | 191 if (bytes_written > 0) total_bytes_written = bytes_written; |
| 191 } else { | 192 } else { |
| 192 // Send data in chunks of maximum 16KB. | 193 // Send data in chunks of maximum 16KB. |
| 193 const intptr_t max_chunk_length = | 194 const intptr_t max_chunk_length = |
| 194 dart::Utils::Minimum(length, static_cast<intptr_t>(16 * KB)); | 195 dart::Utils::Minimum(length, static_cast<intptr_t>(16 * KB)); |
| 195 uint8_t* buffer = new uint8_t[max_chunk_length]; | 196 uint8_t* buffer = new uint8_t[max_chunk_length]; |
| 196 do { | 197 do { |
| 197 intptr_t chunk_length = | 198 intptr_t chunk_length = |
| 198 dart::Utils::Minimum(max_chunk_length, length - total_bytes_written); | 199 dart::Utils::Minimum(max_chunk_length, length - total_bytes_written); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 432 |
| 432 | 433 |
| 433 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { | 434 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { |
| 434 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); | 435 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 435 } | 436 } |
| 436 | 437 |
| 437 | 438 |
| 438 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { | 439 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { |
| 439 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); | 440 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 440 } | 441 } |
| OLD | NEW |