OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "net/cert/cert_database.h" | 11 #include "net/cert/cert_database.h" |
12 #include "net/socket/client_socket_handle.h" | 12 #include "net/socket/client_socket_handle.h" |
| 13 #include "net/socket/ssl_client_socket_openssl.h" |
13 #include "net/socket/tcp_client_socket.h" | 14 #include "net/socket/tcp_client_socket.h" |
14 #include "net/udp/udp_client_socket.h" | 15 #include "net/udp/udp_client_socket.h" |
15 | 16 |
16 #if defined(USE_OPENSSL) | |
17 #include "net/socket/ssl_client_socket_openssl.h" | |
18 #else | |
19 #include "net/socket/ssl_client_socket_nss.h" | |
20 #endif | |
21 | |
22 namespace net { | 17 namespace net { |
23 | 18 |
24 class X509Certificate; | 19 class X509Certificate; |
25 | 20 |
26 namespace { | 21 namespace { |
27 | 22 |
28 class DefaultClientSocketFactory : public ClientSocketFactory, | 23 class DefaultClientSocketFactory : public ClientSocketFactory, |
29 public CertDatabase::Observer { | 24 public CertDatabase::Observer { |
30 public: | 25 public: |
31 DefaultClientSocketFactory() { | 26 DefaultClientSocketFactory() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const NetLog::Source& source) override { | 59 const NetLog::Source& source) override { |
65 return scoped_ptr<StreamSocket>( | 60 return scoped_ptr<StreamSocket>( |
66 new TCPClientSocket(addresses, net_log, source)); | 61 new TCPClientSocket(addresses, net_log, source)); |
67 } | 62 } |
68 | 63 |
69 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( | 64 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( |
70 scoped_ptr<ClientSocketHandle> transport_socket, | 65 scoped_ptr<ClientSocketHandle> transport_socket, |
71 const HostPortPair& host_and_port, | 66 const HostPortPair& host_and_port, |
72 const SSLConfig& ssl_config, | 67 const SSLConfig& ssl_config, |
73 const SSLClientSocketContext& context) override { | 68 const SSLClientSocketContext& context) override { |
74 #if defined(USE_OPENSSL) | |
75 return scoped_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( | 69 return scoped_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( |
76 std::move(transport_socket), host_and_port, ssl_config, context)); | 70 std::move(transport_socket), host_and_port, ssl_config, context)); |
77 #else | |
78 return scoped_ptr<SSLClientSocket>(new SSLClientSocketNSS( | |
79 std::move(transport_socket), host_and_port, ssl_config, context)); | |
80 #endif | |
81 } | 71 } |
82 | 72 |
83 void ClearSSLSessionCache() override { SSLClientSocket::ClearSessionCache(); } | 73 void ClearSSLSessionCache() override { SSLClientSocket::ClearSessionCache(); } |
84 }; | 74 }; |
85 | 75 |
86 static base::LazyInstance<DefaultClientSocketFactory>::Leaky | 76 static base::LazyInstance<DefaultClientSocketFactory>::Leaky |
87 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; | 77 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; |
88 | 78 |
89 } // namespace | 79 } // namespace |
90 | 80 |
91 // static | 81 // static |
92 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { | 82 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { |
93 return g_default_client_socket_factory.Pointer(); | 83 return g_default_client_socket_factory.Pointer(); |
94 } | 84 } |
95 | 85 |
96 } // namespace net | 86 } // namespace net |
OLD | NEW |