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 #include "bin/socket.h" | 5 #include "bin/socket.h" |
| 6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
| 7 #include "bin/thread.h" | 7 #include "bin/thread.h" |
| 8 #include "bin/utils.h" | 8 #include "bin/utils.h" |
| 9 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 } | 32 } |
| 33 Dart_ExitScope(); | 33 Dart_ExitScope(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { | 37 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { |
| 38 Dart_EnterScope(); | 38 Dart_EnterScope(); |
| 39 int64_t socket = DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 39 int64_t socket = DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
| 40 DartUtils::kIdFieldName); | 40 DartUtils::kIdFieldName); |
| 41 intptr_t available = Socket::Available(socket); | 41 intptr_t available = Socket::Available(socket); |
| 42 // TODO(ajohnsen): Consider if we need to queue a calblack for onError. | |
| 43 if (available < 0) available = 0; | |
|
Mads Ager (google)
2012/04/11 07:20:23
I think we need to handle this differently. An err
Anders Johnsen
2012/04/11 07:25:06
Agreed, this is a lot better. I've updated as sugg
| |
| 42 Dart_SetReturnValue(args, Dart_NewInteger(available)); | 44 Dart_SetReturnValue(args, Dart_NewInteger(available)); |
| 43 Dart_ExitScope(); | 45 Dart_ExitScope(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 | 48 |
| 47 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) { | 49 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) { |
| 48 Dart_EnterScope(); | 50 Dart_EnterScope(); |
| 49 intptr_t socket = | 51 intptr_t socket = |
| 50 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 52 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
| 51 DartUtils::kIdFieldName); | 53 DartUtils::kIdFieldName); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 Dart_EnterScope(); | 315 Dart_EnterScope(); |
| 314 Dart_SetReturnValue(args, Dart_Null()); | 316 Dart_SetReturnValue(args, Dart_Null()); |
| 315 Dart_Port service_port = Socket::GetServicePort(); | 317 Dart_Port service_port = Socket::GetServicePort(); |
| 316 if (service_port != kIllegalPort) { | 318 if (service_port != kIllegalPort) { |
| 317 // Return a send port for the service port. | 319 // Return a send port for the service port. |
| 318 Dart_Handle send_port = Dart_NewSendPort(service_port); | 320 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 319 Dart_SetReturnValue(args, send_port); | 321 Dart_SetReturnValue(args, send_port); |
| 320 } | 322 } |
| 321 Dart_ExitScope(); | 323 Dart_ExitScope(); |
| 322 } | 324 } |
| OLD | NEW |