Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
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] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 21 | class DatagramClientSocket; |
[email protected] | 4f4de7e6 | 2010-11-12 19:55:27 | [diff] [blame] | 22 | class HostPortPair; |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 23 | class NetLog; |
| 24 | struct NetLogSource; |
David Benjamin | 24725be | 2019-07-24 20:57:18 | [diff] [blame] | 25 | class SSLClientContext; |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 26 | class SSLClientSocket; |
| 27 | struct SSLConfig; |
Eric Roman | 2bc7716 | 2020-09-16 18:30:45 | [diff] [blame] | 28 | class NetworkQualityEstimator; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 29 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 30 | // An interface used to instantiate StreamSocket objects. Used to facilitate |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 31 | // testing code with mock socket implementations. |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 32 | class NET_EXPORT ClientSocketFactory { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 33 | public: |
Tsuyoshi Horo | 07c3f0e | 2022-06-16 07:30:47 | [diff] [blame] | 34 | virtual ~ClientSocketFactory() = default; |
[email protected] | 836dff3 | 2008-08-05 23:15:36 | [diff] [blame] | 35 | |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 36 | // |source| is the NetLogSource for the entity trying to create the socket, |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 37 | // if it has one. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 38 | virtual std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
[email protected] | 5370c01 | 2011-06-29 03:47:04 | [diff] [blame] | 39 | DatagramSocket::BindType bind_type, |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 40 | NetLog* net_log, |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 41 | const NetLogSource& source) = 0; |
[email protected] | 98b0e58 | 2011-06-22 14:31:41 | [diff] [blame] | 42 | |
Eric Roman | 2bc7716 | 2020-09-16 18:30:45 | [diff] [blame] | 43 | // |network_quality_estimator| is optional. If not specified, the network |
| 44 | // quality will not be considered when determining TCP connect handshake |
| 45 | // timeouts, or when histogramming the handshake duration. |
Helen Li | d5bb922 | 2018-04-12 15:33:09 | [diff] [blame] | 46 | virtual std::unique_ptr<TransportClientSocket> CreateTransportClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 47 | const AddressList& addresses, |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 48 | std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
Eric Roman | 2bc7716 | 2020-09-16 18:30:45 | [diff] [blame] | 49 | NetworkQualityEstimator* network_quality_estimator, |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 50 | NetLog* net_log, |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 51 | const NetLogSource& source) = 0; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 52 | |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 53 | // It is allowed to pass in a StreamSocket that is not obtained from a |
| 54 | // socket pool. The caller could create a StreamSocket directly. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 55 | virtual std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( |
David Benjamin | 24725be | 2019-07-24 20:57:18 | [diff] [blame] | 56 | SSLClientContext* context, |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 57 | std::unique_ptr<StreamSocket> stream_socket, |
Matt Menke | fd95692 | 2019-02-04 23:44:03 | [diff] [blame] | 58 | const HostPortPair& host_and_port, |
David Benjamin | 24725be | 2019-07-24 20:57:18 | [diff] [blame] | 59 | const SSLConfig& ssl_config) = 0; |
[email protected] | e60e47a | 2010-07-14 03:37:18 | [diff] [blame] | 60 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 61 | // Returns the default ClientSocketFactory. |
| 62 | static ClientSocketFactory* GetDefaultFactory(); |
| 63 | }; |
| 64 | |
| 65 | } // namespace net |
| 66 | |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 67 | #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |