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

Side by Side Diff: runtime/bin/socket.cc

Issue 10052007: Socket.available should never return a negative value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698