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