| 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 #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
| 6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class AddressList; | 15 class AddressList; |
| 16 class ClientSocket; | 16 class ClientSocket; |
| 17 class ClientSocketHandle; | 17 class ClientSocketHandle; |
| 18 class DnsRRResolver; | 18 class DnsRRResolver; |
| 19 class SSLClientSocket; | 19 class SSLClientSocket; |
| 20 struct SSLConfig; | 20 struct SSLConfig; |
| 21 class SSLHostInfo; | 21 class SSLHostInfo; |
| 22 | 22 |
| 23 // Callback function to create new SSLClientSocket objects. | 23 // Callback function to create new SSLClientSocket objects. |
| 24 typedef SSLClientSocket* (*SSLClientSocketFactory)( | 24 typedef SSLClientSocket* (*SSLClientSocketFactory)( |
| 25 ClientSocketHandle* transport_socket, | 25 ClientSocketHandle* transport_socket, |
| 26 const std::string& hostname, | 26 const std::string& hostname, |
| 27 uint16 port, |
| 27 const SSLConfig& ssl_config, | 28 const SSLConfig& ssl_config, |
| 28 SSLHostInfo* ssl_host_info, | 29 SSLHostInfo* ssl_host_info, |
| 29 DnsRRResolver* dnsrr_resolver); | 30 DnsRRResolver* dnsrr_resolver); |
| 30 | 31 |
| 31 // An interface used to instantiate ClientSocket objects. Used to facilitate | 32 // An interface used to instantiate ClientSocket objects. Used to facilitate |
| 32 // testing code with mock socket implementations. | 33 // testing code with mock socket implementations. |
| 33 class ClientSocketFactory { | 34 class ClientSocketFactory { |
| 34 public: | 35 public: |
| 35 virtual ~ClientSocketFactory() {} | 36 virtual ~ClientSocketFactory() {} |
| 36 | 37 |
| 37 // |source| is the NetLog::Source for the entity trying to create the socket, | 38 // |source| is the NetLog::Source for the entity trying to create the socket, |
| 38 // if it has one. | 39 // if it has one. |
| 39 virtual ClientSocket* CreateTCPClientSocket( | 40 virtual ClientSocket* CreateTCPClientSocket( |
| 40 const AddressList& addresses, | 41 const AddressList& addresses, |
| 41 NetLog* net_log, | 42 NetLog* net_log, |
| 42 const NetLog::Source& source) = 0; | 43 const NetLog::Source& source) = 0; |
| 43 | 44 |
| 44 virtual SSLClientSocket* CreateSSLClientSocket( | 45 virtual SSLClientSocket* CreateSSLClientSocket( |
| 45 ClientSocketHandle* transport_socket, | 46 ClientSocketHandle* transport_socket, |
| 46 const std::string& hostname, | 47 const std::string& hostname, |
| 48 uint16 port, |
| 47 const SSLConfig& ssl_config, | 49 const SSLConfig& ssl_config, |
| 48 SSLHostInfo* ssl_host_info, | 50 SSLHostInfo* ssl_host_info, |
| 49 DnsRRResolver* dnsrr_resolver) = 0; | 51 DnsRRResolver* dnsrr_resolver) = 0; |
| 50 | 52 |
| 51 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. | 53 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. |
| 52 virtual SSLClientSocket* CreateSSLClientSocket(ClientSocket* transport_socket, | 54 virtual SSLClientSocket* CreateSSLClientSocket(ClientSocket* transport_socket, |
| 53 const std::string& hostname, | 55 const std::string& hostname, |
| 56 uint16 port, |
| 54 const SSLConfig& ssl_config, | 57 const SSLConfig& ssl_config, |
| 55 SSLHostInfo* ssl_host_info); | 58 SSLHostInfo* ssl_host_info); |
| 56 | 59 |
| 57 // Returns the default ClientSocketFactory. | 60 // Returns the default ClientSocketFactory. |
| 58 static ClientSocketFactory* GetDefaultFactory(); | 61 static ClientSocketFactory* GetDefaultFactory(); |
| 59 | 62 |
| 60 // Instructs the default ClientSocketFactory to use |factory| to create | 63 // Instructs the default ClientSocketFactory to use |factory| to create |
| 61 // SSLClientSocket objects. | 64 // SSLClientSocket objects. |
| 62 static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); | 65 static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 } // namespace net | 68 } // namespace net |
| 66 | 69 |
| 67 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 70 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
| OLD | NEW |