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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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
(...skipping 16 matching lines...) Expand all
27 PlatformSocketFactory::~PlatformSocketFactory() { 27 PlatformSocketFactory::~PlatformSocketFactory() {
28 } 28 }
29 29
30 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) { 30 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) {
31 g_socket_factory = factory; 31 g_socket_factory = factory;
32 } 32 }
33 33
34 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) { 34 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) {
35 #if defined(OS_WIN) 35 #if defined(OS_WIN)
36 EnsureWinsockInit(); 36 EnsureWinsockInit();
37 SocketDescriptor result = ::WSASocket(family, type, protocol, NULL, 0, 37 SocketDescriptor result =
38 WSA_FLAG_OVERLAPPED); 38 ::WSASocket(family, type, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
39 if (result != kInvalidSocket && family == AF_INET6 && 39 if (result != kInvalidSocket && family == AF_INET6 &&
40 base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) { 40 base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) {
41 DWORD value = 0; 41 DWORD value = 0;
42 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY, 42 if (setsockopt(result,
43 reinterpret_cast<const char*>(&value), sizeof(value))) { 43 IPPROTO_IPV6,
44 IPV6_V6ONLY,
45 reinterpret_cast<const char*>(&value),
46 sizeof(value))) {
44 closesocket(result); 47 closesocket(result);
45 return kInvalidSocket; 48 return kInvalidSocket;
46 } 49 }
47 } 50 }
48 return result; 51 return result;
49 #else // OS_WIN 52 #else // OS_WIN
50 return ::socket(family, type, protocol); 53 return ::socket(family, type, protocol);
51 #endif // OS_WIN 54 #endif // OS_WIN
52 } 55 }
53 56
54 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) { 57 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
55 if (g_socket_factory) 58 if (g_socket_factory)
56 return g_socket_factory->CreateSocket(family, type, protocol); 59 return g_socket_factory->CreateSocket(family, type, protocol);
57 else 60 else
58 return CreateSocketDefault(family, type, protocol); 61 return CreateSocketDefault(family, type, protocol);
59 } 62 }
60 63
61 } // namespace net 64 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698