| 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 "base/basictypes.h" | 
| 11 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" | 
| 12 | 13 | 
| 13 namespace net { | 14 namespace net { | 
| 14 | 15 | 
| 15 class AddressList; | 16 class AddressList; | 
| 16 class ClientSocket; | 17 class ClientSocket; | 
| 17 class ClientSocketHandle; | 18 class ClientSocketHandle; | 
| 18 class DnsRRResolver; | 19 class DnsRRResolver; | 
|  | 20 class HostPortPair; | 
| 19 class SSLClientSocket; | 21 class SSLClientSocket; | 
| 20 struct SSLConfig; | 22 struct SSLConfig; | 
| 21 class SSLHostInfo; | 23 class SSLHostInfo; | 
| 22 | 24 | 
| 23 // Callback function to create new SSLClientSocket objects. | 25 // Callback function to create new SSLClientSocket objects. | 
| 24 typedef SSLClientSocket* (*SSLClientSocketFactory)( | 26 typedef SSLClientSocket* (*SSLClientSocketFactory)( | 
| 25     ClientSocketHandle* transport_socket, | 27     ClientSocketHandle* transport_socket, | 
| 26     const std::string& hostname, | 28     const HostPortPair& host_and_port, | 
| 27     const SSLConfig& ssl_config, | 29     const SSLConfig& ssl_config, | 
| 28     SSLHostInfo* ssl_host_info, | 30     SSLHostInfo* ssl_host_info, | 
| 29     DnsRRResolver* dnsrr_resolver); | 31     DnsRRResolver* dnsrr_resolver); | 
| 30 | 32 | 
| 31 // An interface used to instantiate ClientSocket objects.  Used to facilitate | 33 // An interface used to instantiate ClientSocket objects.  Used to facilitate | 
| 32 // testing code with mock socket implementations. | 34 // testing code with mock socket implementations. | 
| 33 class ClientSocketFactory { | 35 class ClientSocketFactory { | 
| 34  public: | 36  public: | 
| 35   virtual ~ClientSocketFactory() {} | 37   virtual ~ClientSocketFactory() {} | 
| 36 | 38 | 
| 37   // |source| is the NetLog::Source for the entity trying to create the socket, | 39   // |source| is the NetLog::Source for the entity trying to create the socket, | 
| 38   // if it has one. | 40   // if it has one. | 
| 39   virtual ClientSocket* CreateTCPClientSocket( | 41   virtual ClientSocket* CreateTCPClientSocket( | 
| 40       const AddressList& addresses, | 42       const AddressList& addresses, | 
| 41       NetLog* net_log, | 43       NetLog* net_log, | 
| 42       const NetLog::Source& source) = 0; | 44       const NetLog::Source& source) = 0; | 
| 43 | 45 | 
| 44   virtual SSLClientSocket* CreateSSLClientSocket( | 46   virtual SSLClientSocket* CreateSSLClientSocket( | 
| 45       ClientSocketHandle* transport_socket, | 47       ClientSocketHandle* transport_socket, | 
| 46       const std::string& hostname, | 48       const HostPortPair& host_and_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( | 
| 53                                                  const std::string& hostname, | 55       ClientSocket* transport_socket, | 
| 54                                                  const SSLConfig& ssl_config, | 56       const HostPortPair& host_and_port, | 
| 55                                                  SSLHostInfo* ssl_host_info); | 57       const SSLConfig& ssl_config, | 
|  | 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 | 
|---|