| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const NetLog::Source& source) override { | 60 const NetLog::Source& source) override { |
| 66 return std::unique_ptr<StreamSocket>(new TCPClientSocket( | 61 return std::unique_ptr<StreamSocket>(new TCPClientSocket( |
| 67 addresses, std::move(socket_performance_watcher), net_log, source)); | 62 addresses, std::move(socket_performance_watcher), net_log, source)); |
| 68 } | 63 } |
| 69 | 64 |
| 70 std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( | 65 std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 71 std::unique_ptr<ClientSocketHandle> transport_socket, | 66 std::unique_ptr<ClientSocketHandle> transport_socket, |
| 72 const HostPortPair& host_and_port, | 67 const HostPortPair& host_and_port, |
| 73 const SSLConfig& ssl_config, | 68 const SSLConfig& ssl_config, |
| 74 const SSLClientSocketContext& context) override { | 69 const SSLClientSocketContext& context) override { |
| 75 #if defined(USE_OPENSSL) | |
| 76 return std::unique_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( | 70 return std::unique_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( |
| 77 std::move(transport_socket), host_and_port, ssl_config, context)); | 71 std::move(transport_socket), host_and_port, ssl_config, context)); |
| 78 #else | |
| 79 return std::unique_ptr<SSLClientSocket>(new SSLClientSocketNSS( | |
| 80 std::move(transport_socket), host_and_port, ssl_config, context)); | |
| 81 #endif | |
| 82 } | 72 } |
| 83 | 73 |
| 84 void ClearSSLSessionCache() override { SSLClientSocket::ClearSessionCache(); } | 74 void ClearSSLSessionCache() override { SSLClientSocket::ClearSessionCache(); } |
| 85 }; | 75 }; |
| 86 | 76 |
| 87 static base::LazyInstance<DefaultClientSocketFactory>::Leaky | 77 static base::LazyInstance<DefaultClientSocketFactory>::Leaky |
| 88 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; | 78 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; |
| 89 | 79 |
| 90 } // namespace | 80 } // namespace |
| 91 | 81 |
| 92 // static | 82 // static |
| 93 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { | 83 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { |
| 94 return g_default_client_socket_factory.Pointer(); | 84 return g_default_client_socket_factory.Pointer(); |
| 95 } | 85 } |
| 96 | 86 |
| 97 } // namespace net | 87 } // namespace net |
| OLD | NEW |