[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_ |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 7 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 8 | #include <memory> |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 9 | #include <string> |
| 10 | |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 11 | #include "net/base/net_export.h" |
Helen Li | ac3c51e | 2018-04-24 00:02:13 | [diff] [blame] | 12 | #include "net/http/proxy_client_socket.h" |
tfarina | 5dd13c2 | 2016-11-16 12:08:26 | [diff] [blame] | 13 | #include "net/socket/datagram_socket.h" |
tbansal | ca83c00 | 2016-04-28 20:56:28 | [diff] [blame] | 14 | #include "net/socket/socket_performance_watcher.h" |
Helen Li | d5bb922 | 2018-04-12 15:33:09 | [diff] [blame] | 15 | #include "net/socket/transport_client_socket.h" |
Helen Li | ac3c51e | 2018-04-24 00:02:13 | [diff] [blame] | 16 | #include "net/traffic_annotation/network_traffic_annotation.h" |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 17 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 18 | namespace net { |
| 19 | |
| 20 | class AddressList; |
[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] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 23 | class HostPortPair; |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 24 | class NetLog; |
| 25 | struct NetLogSource; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 26 | class SSLClientSocket; |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 27 | struct SSLClientSocketContext; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 28 | struct SSLConfig; |
Helen Li | ac3c51e | 2018-04-24 00:02:13 | [diff] [blame] | 29 | class ProxyClientSocket; |
| 30 | class HttpAuthController; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 31 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 32 | // An interface used to instantiate StreamSocket objects. Used to facilitate |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 33 | // testing code with mock socket implementations. |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 34 | class NET_EXPORT ClientSocketFactory { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 35 | public: |
[email protected] | 836dff3 | 2008-08-05 23:15:36 | [diff] [blame] | 36 | virtual ~ClientSocketFactory() {} |
| 37 | |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 38 | // |source| is the NetLogSource for the entity trying to create the socket, |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 39 | // if it has one. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 40 | virtual std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
[email protected] | 5370c01 | 2011-06-29 03:47:04 | [diff] [blame] | 41 | DatagramSocket::BindType bind_type, |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 42 | NetLog* net_log, |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 43 | const NetLogSource& source) = 0; |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 44 | |
Helen Li | d5bb922 | 2018-04-12 15:33:09 | [diff] [blame] | 45 | virtual std::unique_ptr<TransportClientSocket> CreateTransportClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 46 | const AddressList& addresses, |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 47 | std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 48 | NetLog* net_log, |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 49 | const NetLogSource& source) = 0; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 50 | |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 51 | // It is allowed to pass in a |transport_socket| that is not obtained from a |
| 52 | // socket pool. The caller could create a ClientSocketHandle directly and call |
| 53 | // set_socket() on it to set a valid StreamSocket instance. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 54 | virtual std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 55 | std::unique_ptr<ClientSocketHandle> transport_socket, |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 56 | const HostPortPair& host_and_port, |
[email protected] | 7ab5bbd1 | 2010-10-19 13:33:21 | [diff] [blame] | 57 | const SSLConfig& ssl_config, |
[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 | |
Helen Li | ac3c51e | 2018-04-24 00:02:13 | [diff] [blame] | 60 | virtual std::unique_ptr<ProxyClientSocket> CreateProxyClientSocket( |
| 61 | std::unique_ptr<ClientSocketHandle> transport_socket, |
| 62 | const std::string& user_agent, |
| 63 | const HostPortPair& endpoint, |
| 64 | HttpAuthController* http_auth_controller, |
| 65 | bool tunnel, |
| 66 | bool using_spdy, |
| 67 | NextProto negotiated_protocol, |
| 68 | bool is_https_proxy, |
| 69 | const NetworkTrafficAnnotationTag& traffic_annotation) = 0; |
| 70 | |
[email protected] | 25f4735 | 2011-02-25 16:31:59 | [diff] [blame] | 71 | // Clears cache used for SSL session resumption. |
| 72 | virtual void ClearSSLSessionCache() = 0; |
| 73 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 74 | // Returns the default ClientSocketFactory. |
| 75 | static ClientSocketFactory* GetDefaultFactory(); |
| 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_ |