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