[email protected] | a2006ece | 2010-04-23 16:44:02 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 5 | #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
| 6 | #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 11 | #include "net/base/net_log.h" |
| 12 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 13 | namespace net { |
| 14 | |
| 15 | class AddressList; |
| 16 | class ClientSocket; |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 17 | class ClientSocketHandle; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 18 | class SSLClientSocket; |
| 19 | struct SSLConfig; |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame^] | 20 | class SSLHostInfo; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 21 | |
[email protected] | abe48d3 | 2010-02-03 02:09:36 | [diff] [blame] | 22 | // Callback function to create new SSLClientSocket objects. |
| 23 | typedef SSLClientSocket* (*SSLClientSocketFactory)( |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 24 | ClientSocketHandle* transport_socket, |
[email protected] | abe48d3 | 2010-02-03 02:09:36 | [diff] [blame] | 25 | const std::string& hostname, |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame^] | 26 | const SSLConfig& ssl_config, |
| 27 | SSLHostInfo* ssl_host_info); |
[email protected] | abe48d3 | 2010-02-03 02:09:36 | [diff] [blame] | 28 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 29 | // An interface used to instantiate ClientSocket objects. Used to facilitate |
| 30 | // testing code with mock socket implementations. |
| 31 | class ClientSocketFactory { |
| 32 | public: |
[email protected] | 836dff3 | 2008-08-05 23:15:36 | [diff] [blame] | 33 | virtual ~ClientSocketFactory() {} |
| 34 | |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 35 | // |source| is the NetLog::Source for the entity trying to create the socket, |
| 36 | // if it has one. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 37 | virtual ClientSocket* CreateTCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 38 | const AddressList& addresses, |
| 39 | NetLog* net_log, |
| 40 | const NetLog::Source& source) = 0; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 41 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 42 | virtual SSLClientSocket* CreateSSLClientSocket( |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 43 | ClientSocketHandle* transport_socket, |
[email protected] | c5949a3 | 2008-10-08 17:28:23 | [diff] [blame] | 44 | const std::string& hostname, |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame^] | 45 | const SSLConfig& ssl_config, |
| 46 | SSLHostInfo* ssl_host_info) = 0; |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 47 | |
| 48 | // Deprecated function (http://crbug.com/37810) that takes a ClientSocket. |
| 49 | virtual SSLClientSocket* CreateSSLClientSocket(ClientSocket* transport_socket, |
| 50 | const std::string& hostname, |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame^] | 51 | const SSLConfig& ssl_config, |
| 52 | SSLHostInfo* ssl_host_info); |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 53 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 54 | // Returns the default ClientSocketFactory. |
| 55 | static ClientSocketFactory* GetDefaultFactory(); |
[email protected] | abe48d3 | 2010-02-03 02:09:36 | [diff] [blame] | 56 | |
| 57 | // Instructs the default ClientSocketFactory to use |factory| to create |
| 58 | // SSLClientSocket objects. |
| 59 | static void SetSSLClientSocketFactory(SSLClientSocketFactory factory); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | } // namespace net |
| 63 | |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 64 | #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |