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

Side by Side Diff: net/socket/socket_descriptor.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
« no previous file with comments | « net/socket/socket.h ('k') | net/socket/socket_test_util.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/socket_descriptor.h" 5 #include "net/socket/socket_descriptor.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #endif 10 #endif
11 11
12 #include "base/basictypes.h"
13
14 #if defined(OS_WIN) 12 #if defined(OS_WIN)
15 #include <ws2tcpip.h> 13 #include <ws2tcpip.h>
16 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
17 #include "net/base/winsock_init.h" 15 #include "net/base/winsock_init.h"
18 #endif 16 #endif
19 17
20 namespace net { 18 namespace net {
21 19
22 PlatformSocketFactory* g_socket_factory = NULL; 20 PlatformSocketFactory* g_socket_factory = nullptr;
23 21
24 PlatformSocketFactory::PlatformSocketFactory() { 22 PlatformSocketFactory::PlatformSocketFactory() {
25 } 23 }
26 24
27 PlatformSocketFactory::~PlatformSocketFactory() { 25 PlatformSocketFactory::~PlatformSocketFactory() {
28 } 26 }
29 27
30 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) { 28 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) {
31 g_socket_factory = factory; 29 g_socket_factory = factory;
32 } 30 }
33 31
34 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) { 32 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) {
35 #if defined(OS_WIN) 33 #if defined(OS_WIN)
36 EnsureWinsockInit(); 34 EnsureWinsockInit();
37 SocketDescriptor result = ::WSASocket(family, type, protocol, NULL, 0, 35 SocketDescriptor result = ::WSASocket(family, type, protocol, nullptr, 0,
38 WSA_FLAG_OVERLAPPED); 36 WSA_FLAG_OVERLAPPED);
39 if (result != kInvalidSocket && family == AF_INET6 && 37 if (result != kInvalidSocket && family == AF_INET6 &&
40 base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) { 38 base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) {
41 DWORD value = 0; 39 DWORD value = 0;
42 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY, 40 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY,
43 reinterpret_cast<const char*>(&value), sizeof(value))) { 41 reinterpret_cast<const char*>(&value), sizeof(value))) {
44 closesocket(result); 42 closesocket(result);
45 return kInvalidSocket; 43 return kInvalidSocket;
46 } 44 }
47 } 45 }
48 return result; 46 return result;
49 #else // OS_WIN 47 #else // OS_WIN
50 return ::socket(family, type, protocol); 48 return ::socket(family, type, protocol);
51 #endif // OS_WIN 49 #endif // OS_WIN
52 } 50 }
53 51
54 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) { 52 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
55 if (g_socket_factory) 53 if (g_socket_factory)
56 return g_socket_factory->CreateSocket(family, type, protocol); 54 return g_socket_factory->CreateSocket(family, type, protocol);
57 else 55 else
58 return CreateSocketDefault(family, type, protocol); 56 return CreateSocketDefault(family, type, protocol);
59 } 57 }
60 58
61 } // namespace net 59 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket.h ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698