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