| 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/base/socket_performance_watcher.h" |
| 12 #include "net/base/socket_performance_watcher_factory.h" |
| 11 #include "net/cert/cert_database.h" | 13 #include "net/cert/cert_database.h" |
| 12 #include "net/socket/client_socket_handle.h" | 14 #include "net/socket/client_socket_handle.h" |
| 13 #include "net/socket/tcp_client_socket.h" | 15 #include "net/socket/tcp_client_socket.h" |
| 14 #include "net/udp/udp_client_socket.h" | 16 #include "net/udp/udp_client_socket.h" |
| 15 | 17 |
| 16 #if defined(USE_OPENSSL) | 18 #if defined(USE_OPENSSL) |
| 17 #include "net/socket/ssl_client_socket_openssl.h" | 19 #include "net/socket/ssl_client_socket_openssl.h" |
| 18 #else | 20 #else |
| 19 #include "net/socket/ssl_client_socket_nss.h" | 21 #include "net/socket/ssl_client_socket_nss.h" |
| 20 #endif | 22 #endif |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 DatagramSocket::BindType bind_type, | 55 DatagramSocket::BindType bind_type, |
| 54 const RandIntCallback& rand_int_cb, | 56 const RandIntCallback& rand_int_cb, |
| 55 NetLog* net_log, | 57 NetLog* net_log, |
| 56 const NetLog::Source& source) override { | 58 const NetLog::Source& source) override { |
| 57 return scoped_ptr<DatagramClientSocket>( | 59 return scoped_ptr<DatagramClientSocket>( |
| 58 new UDPClientSocket(bind_type, rand_int_cb, net_log, source)); | 60 new UDPClientSocket(bind_type, rand_int_cb, net_log, source)); |
| 59 } | 61 } |
| 60 | 62 |
| 61 scoped_ptr<StreamSocket> CreateTransportClientSocket( | 63 scoped_ptr<StreamSocket> CreateTransportClientSocket( |
| 62 const AddressList& addresses, | 64 const AddressList& addresses, |
| 65 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
| 63 NetLog* net_log, | 66 NetLog* net_log, |
| 64 const NetLog::Source& source) override { | 67 const NetLog::Source& source) override { |
| 65 return scoped_ptr<StreamSocket>( | 68 // Create a |SocketPerformanceWatcher|, and pass the ownership to the |
| 66 new TCPClientSocket(addresses, net_log, source)); | 69 // TCPClientSocket. |
| 70 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher; |
| 71 if (socket_performance_watcher_factory) { |
| 72 socket_performance_watcher = |
| 73 socket_performance_watcher_factory->CreateSocketPerformanceWatcher( |
| 74 SocketPerformanceWatcherFactory::PROTOCOL_TCP); |
| 75 } |
| 76 return scoped_ptr<StreamSocket>(new TCPClientSocket( |
| 77 addresses, std::move(socket_performance_watcher), net_log, source)); |
| 67 } | 78 } |
| 68 | 79 |
| 69 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( | 80 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 70 scoped_ptr<ClientSocketHandle> transport_socket, | 81 scoped_ptr<ClientSocketHandle> transport_socket, |
| 71 const HostPortPair& host_and_port, | 82 const HostPortPair& host_and_port, |
| 72 const SSLConfig& ssl_config, | 83 const SSLConfig& ssl_config, |
| 73 const SSLClientSocketContext& context) override { | 84 const SSLClientSocketContext& context) override { |
| 74 #if defined(USE_OPENSSL) | 85 #if defined(USE_OPENSSL) |
| 75 return scoped_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( | 86 return scoped_ptr<SSLClientSocket>(new SSLClientSocketOpenSSL( |
| 76 std::move(transport_socket), host_and_port, ssl_config, context)); | 87 std::move(transport_socket), host_and_port, ssl_config, context)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; | 98 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; |
| 88 | 99 |
| 89 } // namespace | 100 } // namespace |
| 90 | 101 |
| 91 // static | 102 // static |
| 92 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { | 103 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { |
| 93 return g_default_client_socket_factory.Pointer(); | 104 return g_default_client_socket_factory.Pointer(); |
| 94 } | 105 } |
| 95 | 106 |
| 96 } // namespace net | 107 } // namespace net |
| OLD | NEW |