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

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

Issue 2780063002: Pulled a significant portion of Socket implementation into BaseSocket in order to prepare for the s… (Closed)
Patch Set: Minor change to socket_common_unsupported.cc 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 #if !defined(DART_IO_DISABLED)
6
7 #include "bin/socket_common.h"
8 #include "bin/socket.h"
9
10 #include "bin/dartutils.h"
11 #include "bin/io_buffer.h"
12 #include "bin/isolate_data.h"
13 #include "bin/lockers.h"
14 #include "bin/thread.h"
15 #include "bin/utils.h"
16
17 #include "include/dart_api.h"
18
19 #include "platform/globals.h"
20 #include "platform/utils.h"
21
22 namespace dart {
23 namespace bin {
24
25 void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) {
26 const char* address =
27 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
28 ASSERT(address != NULL);
29 RawAddr raw;
30 memset(&raw, 0, sizeof(raw));
31 int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4
32 : SocketAddress::TYPE_IPV6;
33 if (type == SocketAddress::TYPE_IPV4) {
34 raw.addr.sa_family = AF_INET;
35 } else {
36 raw.addr.sa_family = AF_INET6;
37 }
38 bool ok = BaseSocket::ParseAddress(type, address, &raw);
39 if (!ok) {
40 Dart_SetReturnValue(args, Dart_Null());
41 } else {
42 Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw));
43 }
44 }
45
46
47 void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) {
48 Dart_SetReturnValue(args,
49 Dart_NewBoolean(BaseSocket::ListInterfacesSupported()));
50 }
51
52
53 void FUNCTION_NAME(BaseSocket_IsBindError)(Dart_NativeArguments args) {
54 intptr_t error_number =
55 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
56 bool is_bind_error = BaseSocket::IsBindError(error_number);
57 Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False());
58 }
59
60 } // namespace bin
61 } // namespace dart
62
63 #endif // !defined(DART_IO_DISABLED)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698