OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/client_socket_factory.h" | 5 #include "net/socket/client_socket_factory.h" |
6 | 6 |
7 #include "base/singleton.h" | 7 #include "base/lazy_instance.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "net/socket/client_socket_handle.h" | 9 #include "net/socket/client_socket_handle.h" |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include "net/socket/ssl_client_socket_win.h" | 11 #include "net/socket/ssl_client_socket_win.h" |
12 #elif defined(USE_OPENSSL) | 12 #elif defined(USE_OPENSSL) |
13 #include "net/socket/ssl_client_socket_openssl.h" | 13 #include "net/socket/ssl_client_socket_openssl.h" |
14 #elif defined(USE_NSS) | 14 #elif defined(USE_NSS) |
15 #include "net/socket/ssl_client_socket_nss.h" | 15 #include "net/socket/ssl_client_socket_nss.h" |
16 #elif defined(OS_MACOSX) | 16 #elif defined(OS_MACOSX) |
17 #include "net/socket/ssl_client_socket_nss.h" | 17 #include "net/socket/ssl_client_socket_nss.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ClientSocketHandle* transport_socket, | 64 ClientSocketHandle* transport_socket, |
65 const HostPortPair& host_and_port, | 65 const HostPortPair& host_and_port, |
66 const SSLConfig& ssl_config, | 66 const SSLConfig& ssl_config, |
67 SSLHostInfo* ssl_host_info, | 67 SSLHostInfo* ssl_host_info, |
68 DnsCertProvenanceChecker* dns_cert_checker) { | 68 DnsCertProvenanceChecker* dns_cert_checker) { |
69 return g_ssl_factory(transport_socket, host_and_port, ssl_config, | 69 return g_ssl_factory(transport_socket, host_and_port, ssl_config, |
70 ssl_host_info, dns_cert_checker); | 70 ssl_host_info, dns_cert_checker); |
71 } | 71 } |
72 }; | 72 }; |
73 | 73 |
| 74 static base::LazyInstance<DefaultClientSocketFactory> |
| 75 g_default_client_socket_factory(base::LINKER_INITIALIZED); |
| 76 |
74 } // namespace | 77 } // namespace |
75 | 78 |
76 // static | 79 // static |
77 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { | 80 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { |
78 return Singleton<DefaultClientSocketFactory>::get(); | 81 return g_default_client_socket_factory.Pointer(); |
79 } | 82 } |
80 | 83 |
81 // static | 84 // static |
82 void ClientSocketFactory::SetSSLClientSocketFactory( | 85 void ClientSocketFactory::SetSSLClientSocketFactory( |
83 SSLClientSocketFactory factory) { | 86 SSLClientSocketFactory factory) { |
84 g_ssl_factory = factory; | 87 g_ssl_factory = factory; |
85 } | 88 } |
86 | 89 |
87 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. | 90 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. |
88 SSLClientSocket* ClientSocketFactory::CreateSSLClientSocket( | 91 SSLClientSocket* ClientSocketFactory::CreateSSLClientSocket( |
89 ClientSocket* transport_socket, | 92 ClientSocket* transport_socket, |
90 const HostPortPair& host_and_port, | 93 const HostPortPair& host_and_port, |
91 const SSLConfig& ssl_config, | 94 const SSLConfig& ssl_config, |
92 SSLHostInfo* ssl_host_info) { | 95 SSLHostInfo* ssl_host_info) { |
93 ClientSocketHandle* socket_handle = new ClientSocketHandle(); | 96 ClientSocketHandle* socket_handle = new ClientSocketHandle(); |
94 socket_handle->set_socket(transport_socket); | 97 socket_handle->set_socket(transport_socket); |
95 return CreateSSLClientSocket(socket_handle, host_and_port, ssl_config, | 98 return CreateSSLClientSocket(socket_handle, host_and_port, ssl_config, |
96 ssl_host_info, | 99 ssl_host_info, |
97 NULL /* DnsCertProvenanceChecker */); | 100 NULL /* DnsCertProvenanceChecker */); |
98 } | 101 } |
99 | 102 |
100 } // namespace net | 103 } // namespace net |
OLD | NEW |