1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ 6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ 7 8 #include <string> 9 10 namespace net { 11 12 class AddressList; 13 class ClientSocket; 14 class SSLClientSocket; 15 struct SSLConfig; 16 17 // Callback function to create new SSLClientSocket objects. 18 typedef SSLClientSocket* (*SSLClientSocketFactory)( 19 ClientSocket* transport_socket, 20 const std::string& hostname, 21 const SSLConfig& ssl_config); 22 23 // Creates SSLClientSocketNSS objects. 24 SSLClientSocket* SSLClientSocketNSSFactory( 25 ClientSocket* transport_socket, 26 const std::string& hostname, 27 const SSLConfig& ssl_config); 28 29 // An interface used to instantiate ClientSocket objects. Used to facilitate 30 // testing code with mock socket implementations. 31 class ClientSocketFactory { 32 public: 33 virtual ~ClientSocketFactory() {} 34 35 virtual ClientSocket* CreateTCPClientSocket( 36 const AddressList& addresses) = 0; 37 38 virtual SSLClientSocket* CreateSSLClientSocket( 39 ClientSocket* transport_socket, 40 const std::string& hostname, 41 const SSLConfig& ssl_config) = 0; 42 43 // Returns the default ClientSocketFactory. 44 static ClientSocketFactory* GetDefaultFactory(); 45 46 // Instructs the default ClientSocketFactory to use |factory| to create 47 // SSLClientSocket objects. 48 static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); 49 }; 50 51 } // namespace net 52 53 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ 54