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

Unified Diff: runtime/bin/socket.cc

Issue 76383002: Update InternetAddress (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review commetns 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | 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 48acaf37a75f3000954ff3b4ffa8a1d8c9361876..4b6b37785bbeb1078dccea66e74ab22c87c732a1 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -73,11 +73,32 @@ void FUNCTION_NAME(InternetAddress_Fixed)(Dart_NativeArguments args) {
if (Dart_IsError(error)) Dart_PropagateError(error);
Dart_ThrowException(error);
}
- int len = SocketAddress::GetAddrLength(&raw);
- Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, len);
- if (Dart_IsError(result)) Dart_PropagateError(result);
- Dart_ListSetAsBytes(result, 0, reinterpret_cast<uint8_t *>(&raw), len);
- Dart_SetReturnValue(args, result);
+ Dart_SetReturnValue(args, SocketAddress::ToTypedData(&raw));
+}
+
+
+void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) {
+ int64_t type = 0;
+ bool ok = DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &type);
+ ASSERT(ok);
+ USE(ok);
+ const char* address =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
+ ASSERT(address != NULL);
+ RawAddr raw;
+ memset(&raw, 0, sizeof(raw));
+ if (type == SocketAddress::TYPE_IPV4) {
+ raw.addr.sa_family = AF_INET;
+ } else {
+ ASSERT(type == SocketAddress::TYPE_IPV6);
+ raw.addr.sa_family = AF_INET6;
+ }
+ ok = Socket::ParseAddress(type, address, &raw);
+ if (!ok) {
+ Dart_SetReturnValue(args, Dart_Null());
+ } else {
+ Dart_SetReturnValue(args, SocketAddress::ToTypedData(&raw));
+ }
}
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698