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

Unified Diff: runtime/bin/socket_base.cc

Issue 2797993005: Re-land socket refactor with fixes for Windows. (Closed)
Patch Set: Rebased + reverted original revert Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_base.h ('k') | runtime/bin/socket_base_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_base.cc
diff --git a/runtime/bin/socket_base.cc b/runtime/bin/socket_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..caae5025c37d390da32493f8de4dfde93240593b
--- /dev/null
+++ b/runtime/bin/socket_base.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#if !defined(DART_IO_DISABLED)
+
+#include "bin/socket_base.h"
+
+#include "bin/dartutils.h"
+#include "bin/io_buffer.h"
+#include "bin/isolate_data.h"
+#include "bin/lockers.h"
+#include "bin/thread.h"
+#include "bin/utils.h"
+
+#include "include/dart_api.h"
+
+#include "platform/globals.h"
+#include "platform/utils.h"
+
+namespace dart {
+namespace bin {
+
+void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) {
+ const char* address =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ ASSERT(address != NULL);
+ RawAddr raw;
+ memset(&raw, 0, sizeof(raw));
+ int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4
+ : SocketAddress::TYPE_IPV6;
+ if (type == SocketAddress::TYPE_IPV4) {
+ raw.addr.sa_family = AF_INET;
+ } else {
+ raw.addr.sa_family = AF_INET6;
+ }
+ bool ok = SocketBase::ParseAddress(type, address, &raw);
+ if (!ok) {
+ Dart_SetReturnValue(args, Dart_Null());
+ } else {
+ Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw));
+ }
+}
+
+
+void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) {
+ Dart_SetReturnValue(args,
+ Dart_NewBoolean(SocketBase::ListInterfacesSupported()));
+}
+
+
+void FUNCTION_NAME(SocketBase_IsBindError)(Dart_NativeArguments args) {
+ intptr_t error_number =
+ DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
+ bool is_bind_error = SocketBase::IsBindError(error_number);
+ Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False());
+}
+
+} // namespace bin
+} // namespace dart
+
+#endif // !defined(DART_IO_DISABLED)
« no previous file with comments | « runtime/bin/socket_base.h ('k') | runtime/bin/socket_base_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698