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

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

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 | « dart/runtime/bin/socket.h ('k') | dart/runtime/bin/socket_android.cc » ('j') | 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) 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 230
231 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { 231 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) {
232 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); 232 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
233 intptr_t socket = 0; 233 intptr_t socket = 0;
234 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket); 234 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket);
235 if (Dart_IsError(err)) Dart_PropagateError(err); 235 if (Dart_IsError(err)) Dart_PropagateError(err);
236 OSError os_error; 236 OSError os_error;
237 intptr_t port = 0; 237 intptr_t port = 0;
238 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN); 238 SocketAddress* addr = Socket::GetRemotePeer(socket, &port);
239 char host[INET6_ADDRSTRLEN]; 239 if (addr != NULL) {
240 if (Socket::GetRemotePeer(socket, host, &port)) {
241 Dart_Handle list = Dart_NewList(2); 240 Dart_Handle list = Dart_NewList(2);
242 Dart_ListSetAt(list, 0, Dart_NewStringFromCString(host)); 241
242 Dart_Handle entry = Dart_NewList(3);
243 Dart_ListSetAt(entry, 0, Dart_NewInteger(addr->GetType()));
244 Dart_ListSetAt(entry, 1, Dart_NewStringFromCString(addr->as_string()));
245
246 RawAddr raw = addr->addr();
247 intptr_t data_length = SocketAddress::GetAddrLength(&raw);
248 Dart_Handle data = Dart_NewTypedData(Dart_TypedData_kUint8, data_length);
249 Dart_ListSetAsBytes(data, 0, reinterpret_cast<uint8_t*>(&raw), data_length);
250 Dart_ListSetAt(entry, 2, data);
251
252 Dart_ListSetAt(list, 0, entry);
243 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); 253 Dart_ListSetAt(list, 1, Dart_NewInteger(port));
244 Dart_SetReturnValue(args, list); 254 Dart_SetReturnValue(args, list);
255 delete addr;
245 } else { 256 } else {
246 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); 257 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
247 } 258 }
248 } 259 }
249 260
250 261
251 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) { 262 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) {
252 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); 263 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
253 intptr_t socket = 0; 264 intptr_t socket = 0;
254 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket); 265 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); 516 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id);
506 } 517 }
507 518
508 519
509 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { 520 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) {
510 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); 521 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id);
511 } 522 }
512 523
513 } // namespace bin 524 } // namespace bin
514 } // namespace dart 525 } // namespace dart
OLDNEW
« no previous file with comments | « dart/runtime/bin/socket.h ('k') | dart/runtime/bin/socket_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698