[email protected] | 9c4eff2 | 2012-03-20 22:42:29 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |
| 5 | // This class represents contextual information (cookies, cache, etc.) |
ricea | 29e27d1 | 2016-08-10 02:09:18 | [diff] [blame] | 6 | // that's necessary when processing resource requests. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 7 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 8 | #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| 9 | #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 10 | |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 11 | #include <stdint.h> |
danakj | 8522a25b | 2016-04-16 00:17:36 | [diff] [blame] | 12 | #include <memory> |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 13 | #include <set> |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 14 | #include <string> |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 15 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 16 | #include "base/memory/raw_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 17 | #include "base/memory/ref_counted.h" |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 18 | #include "base/memory/weak_ptr.h" |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 19 | #include "base/threading/thread_checker.h" |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 20 | #include "build/build_config.h" |
Yuta Hijikata | 101ed2a | 2020-11-18 07:50:39 | [diff] [blame] | 21 | #include "build/chromeos_buildflags.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 22 | #include "net/base/net_export.h" |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 23 | #include "net/base/network_change_notifier.h" |
[email protected] | 2ca01e5 | 2013-10-31 22:05:19 | [diff] [blame] | 24 | #include "net/base/request_priority.h" |
ainozaki | 7eefe91 | 2021-10-12 03:40:26 | [diff] [blame] | 25 | #include "net/log/net_log_source.h" |
Scott Violet | 0caaaf43 | 2018-03-24 00:43:59 | [diff] [blame] | 26 | #include "net/net_buildflags.h" |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 27 | #include "net/traffic_annotation/network_traffic_annotation.h" |
[email protected] | 8a26ff6 | 2012-08-24 21:49:20 | [diff] [blame] | 28 | #include "net/url_request/url_request.h" |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 29 | #include "third_party/abseil-cpp/absl/types/optional.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 30 | |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 31 | namespace net { |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 32 | class CertVerifier; |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 33 | class CookieStore; |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 34 | class CTPolicyEnforcer; |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 35 | class HostResolver; |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 36 | class HttpAuthHandlerFactory; |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 37 | struct HttpNetworkSessionContext; |
| 38 | struct HttpNetworkSessionParams; |
Matt Menke | ce5d76537 | 2021-08-17 18:24:12 | [diff] [blame] | 39 | class HttpServerProperties; |
[email protected] | b65ce094 | 2009-03-16 20:13:33 | [diff] [blame] | 40 | class HttpTransactionFactory; |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 41 | class HttpUserAgentSettings; |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 42 | class NetLog; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 43 | class NetworkDelegate; |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 44 | class NetworkQualityEstimator; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 45 | class ProxyDelegate; |
Nicolas Arciniega | 8ec5bfa | 2020-03-20 05:07:26 | [diff] [blame] | 46 | class ProxyResolutionService; |
Victor Vasiliev | 7752898d | 2019-11-14 21:30:22 | [diff] [blame] | 47 | class QuicContext; |
Chris Thompson | f31b249 | 2020-07-21 05:47:42 | [diff] [blame] | 48 | class SCTAuditingDelegate; |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 49 | class SSLConfigService; |
Matt Menke | ce5d76537 | 2021-08-17 18:24:12 | [diff] [blame] | 50 | class TransportSecurityState; |
[email protected] | eaadd905 | 2009-06-23 18:02:23 | [diff] [blame] | 51 | class URLRequest; |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 52 | class URLRequestJobFactory; |
[email protected] | a73a280 | 2012-05-02 19:20:15 | [diff] [blame] | 53 | class URLRequestThrottlerManager; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 54 | |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 55 | #if BUILDFLAG(ENABLE_REPORTING) |
Julia Tuttle | cba7d22 | 2018-02-23 19:37:27 | [diff] [blame] | 56 | class NetworkErrorLoggingService; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 57 | class ReportingService; |
| 58 | #endif // BUILDFLAG(ENABLE_REPORTING) |
| 59 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 60 | // Subclass to provide application-specific context for URLRequest |
ricea | 29e27d1 | 2016-08-10 02:09:18 | [diff] [blame] | 61 | // instances. URLRequestContext does not own these member variables, since they |
| 62 | // may be shared with other contexts. URLRequestContextStorage can be used for |
| 63 | // automatic lifetime management. Most callers should use an existing |
| 64 | // URLRequestContext rather than creating a new one, as guaranteeing that the |
| 65 | // URLRequestContext is destroyed before its members can be difficult. |
Kenichi Ishibashi | a92b965 | 2021-09-10 23:43:44 | [diff] [blame] | 66 | class NET_EXPORT URLRequestContext { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 67 | public: |
Maks Orlovich | 9fdb727 | 2019-12-13 01:28:23 | [diff] [blame] | 68 | URLRequestContext(); |
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame] | 69 | |
| 70 | URLRequestContext(const URLRequestContext&) = delete; |
| 71 | URLRequestContext& operator=(const URLRequestContext&) = delete; |
| 72 | |
Kenichi Ishibashi | a92b965 | 2021-09-10 23:43:44 | [diff] [blame] | 73 | virtual ~URLRequestContext(); |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 74 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 75 | // May return nullptr if this context doesn't have an associated network |
| 76 | // session. |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 77 | const HttpNetworkSessionParams* GetNetworkSessionParams() const; |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 78 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 79 | // May return nullptr if this context doesn't have an associated network |
| 80 | // session. |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 81 | const HttpNetworkSessionContext* GetNetworkSessionContext() const; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 82 | |
Yuta Hijikata | 101ed2a | 2020-11-18 07:50:39 | [diff] [blame] | 83 | // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is |
| 84 | // complete. |
Xiaohan Wang | 2a6845b | 2022-01-08 04:40:57 | [diff] [blame] | 85 | #if !BUILDFLAG(IS_WIN) && \ |
| 86 | !(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 87 | // This function should not be used in Chromium, please use the version with |
| 88 | // NetworkTrafficAnnotationTag in the future. |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 89 | // |
| 90 | // The unannotated method is not available on desktop Linux + Windows. It's |
| 91 | // available on other platforms, since we only audit network annotations on |
| 92 | // Linux & Windows. |
danakj | 8522a25b | 2016-04-16 00:17:36 | [diff] [blame] | 93 | std::unique_ptr<URLRequest> CreateRequest( |
| 94 | const GURL& url, |
| 95 | RequestPriority priority, |
| 96 | URLRequest::Delegate* delegate) const; |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 97 | #endif |
[email protected] | 8a26ff6 | 2012-08-24 21:49:20 | [diff] [blame] | 98 | |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 99 | // `traffic_annotation` is metadata about the network traffic send via this |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 100 | // URLRequest, see net::DefineNetworkTrafficAnnotation. Note that: |
| 101 | // - net provides the API for tagging requests with an opaque identifier. |
Nicolas Ouellet-Payeur | 326a269 | 2021-07-15 01:17:33 | [diff] [blame] | 102 | // - chrome/browser/privacy/traffic_annotation.proto contains the Chrome |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 103 | // specific .proto describing the verbose annotation format that Chrome's |
| 104 | // callsites are expected to follow. |
| 105 | // - tools/traffic_annotation/ contains sample and template for annotation and |
| 106 | // tools will be added for verification following crbug.com/690323. |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 107 | // |
| 108 | // `is_for_websockets` should be true iff this was created for use by a |
| 109 | // websocket. HTTP/HTTPS requests fail if it's true, and WS/WSS requests fail |
| 110 | // if it's false. This is to protect against broken consumers. |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 111 | // |
| 112 | // `net_log_source_id` is used to construct NetLogWithSource using the |
| 113 | // specified Source ID. This method is expected to be used when URLRequest |
| 114 | // wants to take over existing NetLogSource. |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 115 | std::unique_ptr<URLRequest> CreateRequest( |
| 116 | const GURL& url, |
| 117 | RequestPriority priority, |
| 118 | URLRequest::Delegate* delegate, |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 119 | NetworkTrafficAnnotationTag traffic_annotation, |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 120 | bool is_for_websockets = false, |
ainozaki | 7eefe91 | 2021-10-12 03:40:26 | [diff] [blame] | 121 | const absl::optional<net::NetLogSource> net_log_source = |
| 122 | absl::nullopt) const; |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 123 | |
| 124 | NetLog* net_log() const { return net_log_; } |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 125 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 126 | void set_net_log(NetLog* net_log) { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 127 | net_log_ = net_log; |
| 128 | } |
| 129 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 130 | HostResolver* host_resolver() const { |
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 131 | return host_resolver_; |
| 132 | } |
| 133 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 134 | void set_host_resolver(HostResolver* host_resolver) { |
Eric Orth | 5d9958c | 2019-09-27 20:43:18 | [diff] [blame] | 135 | DCHECK(host_resolver); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 136 | host_resolver_ = host_resolver; |
| 137 | } |
| 138 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 139 | CertVerifier* cert_verifier() const { |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 140 | return cert_verifier_; |
| 141 | } |
| 142 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 143 | void set_cert_verifier(CertVerifier* cert_verifier) { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 144 | cert_verifier_ = cert_verifier; |
| 145 | } |
| 146 | |
[email protected] | 63de95b | 2008-12-10 04:11:27 | [diff] [blame] | 147 | // Get the proxy service for this context. |
Nicolas Arciniega | 8ec5bfa | 2020-03-20 05:07:26 | [diff] [blame] | 148 | ProxyResolutionService* proxy_resolution_service() const { |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 149 | return proxy_resolution_service_; |
| 150 | } |
| 151 | void set_proxy_resolution_service( |
Nicolas Arciniega | 8ec5bfa | 2020-03-20 05:07:26 | [diff] [blame] | 152 | ProxyResolutionService* proxy_resolution_service) { |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 153 | proxy_resolution_service_ = proxy_resolution_service; |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 154 | } |
| 155 | |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 156 | ProxyDelegate* proxy_delegate() const { return proxy_delegate_; } |
| 157 | void set_proxy_delegate(ProxyDelegate* proxy_delegate) { |
| 158 | proxy_delegate_ = proxy_delegate; |
| 159 | } |
| 160 | |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 161 | // Get the ssl config service for this context. |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 162 | SSLConfigService* ssl_config_service() const { return ssl_config_service_; } |
| 163 | void set_ssl_config_service(SSLConfigService* service) { |
| 164 | ssl_config_service_ = service; |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 165 | } |
| 166 | |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 167 | // Gets the HTTP Authentication Handler Factory for this context. |
| 168 | // The factory is only valid for the lifetime of this URLRequestContext |
[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 169 | HttpAuthHandlerFactory* http_auth_handler_factory() const { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 170 | return http_auth_handler_factory_; |
| 171 | } |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 172 | void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 173 | http_auth_handler_factory_ = factory; |
| 174 | } |
| 175 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 176 | // Gets the http transaction factory for this context. |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 177 | HttpTransactionFactory* http_transaction_factory() const { |
[email protected] | db8f44c | 2008-12-13 04:52:01 | [diff] [blame] | 178 | return http_transaction_factory_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 179 | } |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 180 | void set_http_transaction_factory(HttpTransactionFactory* factory) { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 181 | http_transaction_factory_ = factory; |
| 182 | } |
| 183 | |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 184 | void set_network_delegate(NetworkDelegate* network_delegate) { |
[email protected] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame] | 185 | network_delegate_ = network_delegate; |
| 186 | } |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 187 | NetworkDelegate* network_delegate() const { return network_delegate_; } |
[email protected] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame] | 188 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 189 | void set_http_server_properties( |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 190 | HttpServerProperties* http_server_properties) { |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 191 | http_server_properties_ = http_server_properties; |
| 192 | } |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 193 | HttpServerProperties* http_server_properties() const { |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 194 | return http_server_properties_; |
| 195 | } |
| 196 | |
[email protected] | be6fca6c | 2010-01-30 21:48:57 | [diff] [blame] | 197 | // Gets the cookie store for this context (may be null, in which case |
| 198 | // cookies are not stored). |
mmenke | 606c59c | 2016-03-07 18:20:55 | [diff] [blame] | 199 | CookieStore* cookie_store() const { return cookie_store_; } |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 200 | void set_cookie_store(CookieStore* cookie_store); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 201 | |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 202 | TransportSecurityState* transport_security_state() const { |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 203 | return transport_security_state_; |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 204 | } |
| 205 | void set_transport_security_state( |
[email protected] | 7461a40 | 2011-03-24 23:19:51 | [diff] [blame] | 206 | TransportSecurityState* state) { |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 207 | transport_security_state_ = state; |
| 208 | } |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 209 | |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 210 | CTPolicyEnforcer* ct_policy_enforcer() const { return ct_policy_enforcer_; } |
| 211 | void set_ct_policy_enforcer(CTPolicyEnforcer* enforcer) { |
| 212 | ct_policy_enforcer_ = enforcer; |
| 213 | } |
| 214 | |
Chris Thompson | f31b249 | 2020-07-21 05:47:42 | [diff] [blame] | 215 | SCTAuditingDelegate* sct_auditing_delegate() const { |
| 216 | return sct_auditing_delegate_; |
| 217 | } |
| 218 | void set_sct_auditing_delegate(SCTAuditingDelegate* delegate) { |
| 219 | sct_auditing_delegate_ = delegate; |
| 220 | } |
| 221 | |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 222 | const URLRequestJobFactory* job_factory() const { return job_factory_; } |
| 223 | void set_job_factory(const URLRequestJobFactory* job_factory) { |
| 224 | job_factory_ = job_factory; |
| 225 | } |
| 226 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 227 | // May return nullptr. |
[email protected] | a73a280 | 2012-05-02 19:20:15 | [diff] [blame] | 228 | URLRequestThrottlerManager* throttler_manager() const { |
| 229 | return throttler_manager_; |
| 230 | } |
| 231 | void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) { |
| 232 | throttler_manager_ = throttler_manager; |
| 233 | } |
| 234 | |
Victor Vasiliev | 7752898d | 2019-11-14 21:30:22 | [diff] [blame] | 235 | QuicContext* quic_context() const { return quic_context_; } |
| 236 | void set_quic_context(QuicContext* quic_context) { |
| 237 | quic_context_ = quic_context; |
| 238 | } |
| 239 | |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 240 | // Gets the URLRequest objects that hold a reference to this |
| 241 | // URLRequestContext. |
Helen Li | f5e4a75 | 2018-01-02 16:03:02 | [diff] [blame] | 242 | std::set<const URLRequest*>* url_requests() const { |
| 243 | return url_requests_.get(); |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | 42455949 | 2014-07-22 00:27:40 | [diff] [blame] | 246 | // CHECKs that no URLRequests using this context remain. Subclasses should |
| 247 | // additionally call AssertNoURLRequests() within their own destructor, |
| 248 | // prior to implicit destruction of subclass-owned state. |
[email protected] | 1e714bba | 2012-04-10 17:01:05 | [diff] [blame] | 249 | void AssertNoURLRequests() const; |
| 250 | |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 251 | // Get the underlying |HttpUserAgentSettings| implementation that provides |
[email protected] | 84f0543 | 2013-03-15 01:00:12 | [diff] [blame] | 252 | // the HTTP Accept-Language and User-Agent header values. |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 253 | const HttpUserAgentSettings* http_user_agent_settings() const { |
| 254 | return http_user_agent_settings_; |
| 255 | } |
| 256 | void set_http_user_agent_settings( |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 257 | const HttpUserAgentSettings* http_user_agent_settings) { |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 258 | http_user_agent_settings_ = http_user_agent_settings; |
| 259 | } |
| 260 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 261 | // Gets the NetworkQualityEstimator associated with this context. |
| 262 | // May return nullptr. |
| 263 | NetworkQualityEstimator* network_quality_estimator() const { |
| 264 | return network_quality_estimator_; |
| 265 | } |
| 266 | void set_network_quality_estimator( |
| 267 | NetworkQualityEstimator* network_quality_estimator) { |
| 268 | network_quality_estimator_ = network_quality_estimator; |
| 269 | } |
| 270 | |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 271 | #if BUILDFLAG(ENABLE_REPORTING) |
juliatuttle | 2b8dd2d1 | 2017-04-12 21:27:41 | [diff] [blame] | 272 | ReportingService* reporting_service() const { return reporting_service_; } |
| 273 | void set_reporting_service(ReportingService* reporting_service) { |
| 274 | reporting_service_ = reporting_service; |
| 275 | } |
| 276 | |
Julia Tuttle | cba7d22 | 2018-02-23 19:37:27 | [diff] [blame] | 277 | NetworkErrorLoggingService* network_error_logging_service() const { |
| 278 | return network_error_logging_service_; |
Julia Tuttle | f9b7406 | 2017-07-27 14:44:05 | [diff] [blame] | 279 | } |
Julia Tuttle | cba7d22 | 2018-02-23 19:37:27 | [diff] [blame] | 280 | void set_network_error_logging_service( |
| 281 | NetworkErrorLoggingService* network_error_logging_service) { |
| 282 | network_error_logging_service_ = network_error_logging_service; |
Julia Tuttle | f9b7406 | 2017-07-27 14:44:05 | [diff] [blame] | 283 | } |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 284 | #endif // BUILDFLAG(ENABLE_REPORTING) |
Julia Tuttle | f9b7406 | 2017-07-27 14:44:05 | [diff] [blame] | 285 | |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 286 | void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } |
| 287 | |
| 288 | bool enable_brotli() const { return enable_brotli_; } |
| 289 | |
mgersh | d21d6d14 | 2016-12-14 23:06:36 | [diff] [blame] | 290 | // Sets the |check_cleartext_permitted| flag, which controls whether to check |
| 291 | // system policy before allowing a cleartext http or ws request. |
| 292 | void set_check_cleartext_permitted(bool check_cleartext_permitted) { |
| 293 | check_cleartext_permitted_ = check_cleartext_permitted; |
| 294 | } |
| 295 | |
| 296 | // Returns current value of the |check_cleartext_permitted| flag. |
| 297 | bool check_cleartext_permitted() const { return check_cleartext_permitted_; } |
| 298 | |
Matt Menke | ee10f041 | 2020-05-14 14:16:03 | [diff] [blame] | 299 | void set_require_network_isolation_key(bool require_network_isolation_key) { |
| 300 | require_network_isolation_key_ = require_network_isolation_key; |
| 301 | } |
| 302 | bool require_network_isolation_key() const { |
| 303 | return require_network_isolation_key_; |
| 304 | } |
| 305 | |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 306 | // If != NetworkChangeNotifier::kInvalidNetworkHandle, the network which this |
| 307 | // context has been bound to. |
| 308 | NetworkChangeNotifier::NetworkHandle bound_network() const { |
| 309 | return bound_network_; |
| 310 | } |
| 311 | void set_bound_network(NetworkChangeNotifier::NetworkHandle network) { |
| 312 | bound_network_ = network; |
| 313 | } |
| 314 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 315 | void AssertCalledOnValidThread() { |
| 316 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 317 | } |
| 318 | |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 319 | private: |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 320 | // Ownership for these members are not defined here. Clients should either |
| 321 | // provide storage elsewhere or have a subclass take ownership. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 322 | raw_ptr<NetLog> net_log_; |
| 323 | raw_ptr<HostResolver> host_resolver_; |
| 324 | raw_ptr<CertVerifier> cert_verifier_; |
| 325 | raw_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
| 326 | raw_ptr<ProxyResolutionService> proxy_resolution_service_; |
| 327 | raw_ptr<ProxyDelegate> proxy_delegate_; |
| 328 | raw_ptr<SSLConfigService> ssl_config_service_; |
| 329 | raw_ptr<NetworkDelegate> network_delegate_; |
| 330 | raw_ptr<HttpServerProperties> http_server_properties_; |
| 331 | raw_ptr<const HttpUserAgentSettings> http_user_agent_settings_; |
| 332 | raw_ptr<CookieStore> cookie_store_; |
| 333 | raw_ptr<TransportSecurityState> transport_security_state_; |
| 334 | raw_ptr<CTPolicyEnforcer> ct_policy_enforcer_; |
| 335 | raw_ptr<SCTAuditingDelegate> sct_auditing_delegate_; |
| 336 | raw_ptr<HttpTransactionFactory> http_transaction_factory_; |
| 337 | raw_ptr<const URLRequestJobFactory> job_factory_; |
| 338 | raw_ptr<URLRequestThrottlerManager> throttler_manager_; |
| 339 | raw_ptr<QuicContext> quic_context_; |
| 340 | raw_ptr<NetworkQualityEstimator> network_quality_estimator_; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 341 | #if BUILDFLAG(ENABLE_REPORTING) |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 342 | raw_ptr<ReportingService> reporting_service_; |
| 343 | raw_ptr<NetworkErrorLoggingService> network_error_logging_service_; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 344 | #endif // BUILDFLAG(ENABLE_REPORTING) |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 345 | |
Helen Li | f5e4a75 | 2018-01-02 16:03:02 | [diff] [blame] | 346 | std::unique_ptr<std::set<const URLRequest*>> url_requests_; |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 347 | |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 348 | // Enables Brotli Content-Encoding support. |
| 349 | bool enable_brotli_; |
mgersh | d21d6d14 | 2016-12-14 23:06:36 | [diff] [blame] | 350 | // Enables checking system policy before allowing a cleartext http or ws |
| 351 | // request. Only used on Android. |
| 352 | bool check_cleartext_permitted_; |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 353 | |
Matt Menke | ee10f041 | 2020-05-14 14:16:03 | [diff] [blame] | 354 | // Triggers a DCHECK if a NetworkIsolationKey/IsolationInfo is not provided to |
| 355 | // a request when true. |
| 356 | bool require_network_isolation_key_; |
| 357 | |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 358 | NetworkChangeNotifier::NetworkHandle bound_network_; |
| 359 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 360 | THREAD_CHECKER(thread_checker_); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 361 | }; |
| 362 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 363 | } // namespace net |
| 364 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 365 | #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |