| 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> | |
| 10 | |
| 11 namespace net { | 9 namespace net { |
| 12 | 10 |
| 13 class AddressList; | 11 class AddressList; |
| 14 class ClientSocket; | 12 class ClientSocket; |
| 15 class ClientSocketHandle; | 13 class ClientSocketHandle; |
| 14 class HostPortPair; |
| 16 class NetLog; | 15 class NetLog; |
| 17 class SSLClientSocket; | 16 class SSLClientSocket; |
| 18 struct SSLConfig; | 17 struct SSLConfig; |
| 19 | 18 |
| 20 // Callback function to create new SSLClientSocket objects. | 19 // Callback function to create new SSLClientSocket objects. |
| 21 typedef SSLClientSocket* (*SSLClientSocketFactory)( | 20 typedef SSLClientSocket* (*SSLClientSocketFactory)( |
| 22 ClientSocketHandle* transport_socket, | 21 ClientSocketHandle* transport_socket, |
| 23 const std::string& hostname, | 22 const HostPortPair& host_port_pair, |
| 24 const SSLConfig& ssl_config); | 23 const SSLConfig& ssl_config); |
| 25 | 24 |
| 26 // An interface used to instantiate ClientSocket objects. Used to facilitate | 25 // An interface used to instantiate ClientSocket objects. Used to facilitate |
| 27 // testing code with mock socket implementations. | 26 // testing code with mock socket implementations. |
| 28 class ClientSocketFactory { | 27 class ClientSocketFactory { |
| 29 public: | 28 public: |
| 30 virtual ~ClientSocketFactory() {} | 29 virtual ~ClientSocketFactory() {} |
| 31 | 30 |
| 32 virtual ClientSocket* CreateTCPClientSocket( | 31 virtual ClientSocket* CreateTCPClientSocket( |
| 33 const AddressList& addresses, NetLog* net_log) = 0; | 32 const AddressList& addresses, NetLog* net_log) = 0; |
| 34 | 33 |
| 35 virtual SSLClientSocket* CreateSSLClientSocket( | 34 virtual SSLClientSocket* CreateSSLClientSocket( |
| 36 ClientSocketHandle* transport_socket, | 35 ClientSocketHandle* transport_socket, |
| 37 const std::string& hostname, | 36 const HostPortPair& host_port_pair, |
| 38 const SSLConfig& ssl_config) = 0; | 37 const SSLConfig& ssl_config) = 0; |
| 39 | 38 |
| 40 | 39 |
| 41 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. | 40 // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. |
| 42 virtual SSLClientSocket* CreateSSLClientSocket(ClientSocket* transport_socket, | 41 virtual SSLClientSocket* CreateSSLClientSocket(ClientSocket* transport_socket, |
| 43 const std::string& hostname, | 42 const HostPortPair& hostname, |
| 44 const SSLConfig& ssl_config); | 43 const SSLConfig& ssl_config); |
| 45 | 44 |
| 46 // Returns the default ClientSocketFactory. | 45 // Returns the default ClientSocketFactory. |
| 47 static ClientSocketFactory* GetDefaultFactory(); | 46 static ClientSocketFactory* GetDefaultFactory(); |
| 48 | 47 |
| 49 // Instructs the default ClientSocketFactory to use |factory| to create | 48 // Instructs the default ClientSocketFactory to use |factory| to create |
| 50 // SSLClientSocket objects. | 49 // SSLClientSocket objects. |
| 51 static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); | 50 static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 } // namespace net | 53 } // namespace net |
| 55 | 54 |
| 56 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 55 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
| OLD | NEW |