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

Unified Diff: runtime/bin/socket.cc

Issue 17611010: Remove dead code and re-enable short socket read (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket.cc
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
index a5e64dd2095f712c06bc49b5ae86eb603353494e..47c2aa67362cd0fda21b91b57652b253a7d16aa8 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -130,6 +130,7 @@ void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) {
void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) {
Dart_EnterScope();
+ static bool short_socket_reads = Dart_IsVMFlagSet("short_socket_read");
Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
intptr_t socket = 0;
Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket);
@@ -142,6 +143,9 @@ void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) {
if (length == -1 || available < length) {
length = available;
}
+ if (short_socket_reads) {
+ length = (length + 1) / 2;
+ }
uint8_t* buffer = NULL;
Dart_Handle result = IOBuffer::Allocate(length, &buffer);
if (Dart_IsError(result)) Dart_PropagateError(result);
@@ -175,57 +179,6 @@ void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) {
}
-void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) {
- Dart_EnterScope();
- static bool short_socket_reads = Dart_IsVMFlagSet("short_socket_read");
- Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
- intptr_t socket = 0;
- Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket);
- if (Dart_IsError(err)) Dart_PropagateError(err);
- Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
- int64_t offset = 0;
- int64_t length = 0;
- Dart_Handle offset_obj = Dart_GetNativeArgument(args, 2);
- Dart_Handle length_obj = Dart_GetNativeArgument(args, 3);
- if (Dart_IsList(buffer_obj) &&
- DartUtils::GetInt64Value(offset_obj, &offset) &&
- DartUtils::GetInt64Value(length_obj, &length)) {
- intptr_t buffer_len = 0;
- Dart_Handle result = Dart_ListLength(buffer_obj, &buffer_len);
- if (Dart_IsError(result)) {
- Dart_PropagateError(result);
- }
- ASSERT((offset + length) <= buffer_len);
- if (short_socket_reads) {
- length = (length + 1) / 2;
- }
- uint8_t* buffer = new uint8_t[length];
- intptr_t bytes_read = Socket::Read(socket, buffer, length);
- if (bytes_read > 0) {
- Dart_Handle result =
- Dart_ListSetAsBytes(buffer_obj, offset, buffer, bytes_read);
- if (Dart_IsError(result)) {
- delete[] buffer;
- Dart_PropagateError(result);
- }
- }
- delete[] buffer;
- if (bytes_read >= 0) {
- Dart_SetReturnValue(args, Dart_NewInteger(bytes_read));
- } else {
- Dart_SetReturnValue(args, DartUtils::NewDartOSError());
- }
- } else {
- OSError os_error(-1, "Invalid argument", OSError::kUnknown);
- Dart_Handle err = DartUtils::NewDartOSError(&os_error);
- if (Dart_IsError(err)) Dart_PropagateError(err);
- Dart_SetReturnValue(args, err);
- }
-
- Dart_ExitScope();
-}
-
-
void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
Dart_EnterScope();
static bool short_socket_writes = Dart_IsVMFlagSet("short_socket_write");
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698