[email protected] | f898601 | 2011-05-19 21:53:58 | [diff] [blame] | 1 | // Copyright (c) 2011 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] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 11 | #include "base/basictypes.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 12 | #include "net/base/net_export.h" |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 13 | #include "net/base/net_log.h" |
[email protected] | 5370c01 | 2011-06-29 03:47:04 | [diff] [blame] | 14 | #include "net/base/rand_callback.h" |
| 15 | #include "net/udp/datagram_socket.h" |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 16 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 17 | namespace net { |
| 18 | |
| 19 | class AddressList; |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 20 | class CertVerifier; |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 21 | class ClientSocketHandle; |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 22 | class DatagramClientSocket; |
[email protected] | 345c613b | 2010-11-22 19:33:18 | [diff] [blame] | 23 | class DnsCertProvenanceChecker; |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 24 | class HostPortPair; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 25 | class SSLClientSocket; |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 26 | struct SSLClientSocketContext; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 27 | struct SSLConfig; |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame] | 28 | class SSLHostInfo; |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 29 | class StreamSocket; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 30 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 31 | // An interface used to instantiate StreamSocket objects. Used to facilitate |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 32 | // testing code with mock socket implementations. |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 33 | class NET_EXPORT ClientSocketFactory { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 34 | public: |
[email protected] | 836dff3 | 2008-08-05 23:15:36 | [diff] [blame] | 35 | virtual ~ClientSocketFactory() {} |
| 36 | |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 37 | // |source| is the NetLog::Source for the entity trying to create the socket, |
| 38 | // if it has one. |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 39 | virtual DatagramClientSocket* CreateDatagramClientSocket( |
[email protected] | 5370c01 | 2011-06-29 03:47:04 | [diff] [blame] | 40 | DatagramSocket::BindType bind_type, |
| 41 | const RandIntCallback& rand_int_cb, |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 42 | NetLog* net_log, |
| 43 | const NetLog::Source& source) = 0; |
| 44 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 45 | virtual StreamSocket* CreateTransportClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 46 | const AddressList& addresses, |
| 47 | NetLog* net_log, |
| 48 | const NetLog::Source& source) = 0; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 49 | |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame^] | 50 | // It is allowed to pass in a |transport_socket| that is not obtained from a |
| 51 | // socket pool. The caller could create a ClientSocketHandle directly and call |
| 52 | // set_socket() on it to set a valid StreamSocket instance. |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 53 | virtual SSLClientSocket* CreateSSLClientSocket( |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 54 | ClientSocketHandle* transport_socket, |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 55 | const HostPortPair& host_and_port, |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame] | 56 | const SSLConfig& ssl_config, |
[email protected] | d8fbf58 | 2010-11-04 21:51:12 | [diff] [blame] | 57 | SSLHostInfo* ssl_host_info, |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 58 | const SSLClientSocketContext& context) = 0; |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 59 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 60 | // Deprecated function (http://crbug.com/37810) that takes a StreamSocket. |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 61 | virtual SSLClientSocket* CreateSSLClientSocket( |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 62 | StreamSocket* transport_socket, |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 63 | const HostPortPair& host_and_port, |
| 64 | const SSLConfig& ssl_config, |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 65 | SSLHostInfo* ssl_host_info, |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 66 | const SSLClientSocketContext& context); |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 67 | |
[email protected] | 25f4735 | 2011-02-25 16:31:59 | [diff] [blame] | 68 | // Clears cache used for SSL session resumption. |
| 69 | virtual void ClearSSLSessionCache() = 0; |
| 70 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 71 | // Returns the default ClientSocketFactory. |
| 72 | static ClientSocketFactory* GetDefaultFactory(); |
[email protected] | abe48d3 | 2010-02-03 02:09:36 | [diff] [blame] | 73 | |
[email protected] | 2380f37 | 2011-02-23 21:35:19 | [diff] [blame] | 74 | // Instructs the default ClientSocketFactory to use the system SSL library. |
| 75 | static void UseSystemSSL(); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace net |
| 79 | |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 80 | #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |