| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This class represents contextual information (cookies, cache, etc.) | 5 // This class represents contextual information (cookies, cache, etc.) |
| 6 // that's necessary when processing resource requests. | 6 // that's necessary when processing resource requests. |
| 7 | 7 |
| 8 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 8 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| 9 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 9 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "base/trace_event/memory_dump_provider.h" |
| 19 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
| 20 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 21 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
| 23 #include "net/http/transport_security_state.h" | 24 #include "net/http/transport_security_state.h" |
| 24 #include "net/ssl/ssl_config_service.h" | 25 #include "net/ssl/ssl_config_service.h" |
| 25 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
| 26 | 27 |
| 28 namespace base { |
| 29 namespace trace_event { |
| 30 class ProcessMemoryDump; |
| 31 } |
| 32 } |
| 33 |
| 27 namespace net { | 34 namespace net { |
| 28 class CertVerifier; | 35 class CertVerifier; |
| 29 class ChannelIDService; | 36 class ChannelIDService; |
| 30 class CookieStore; | 37 class CookieStore; |
| 31 class CTPolicyEnforcer; | 38 class CTPolicyEnforcer; |
| 32 class CTVerifier; | 39 class CTVerifier; |
| 33 class HostResolver; | 40 class HostResolver; |
| 34 class HttpAuthHandlerFactory; | 41 class HttpAuthHandlerFactory; |
| 35 class HttpTransactionFactory; | 42 class HttpTransactionFactory; |
| 36 class HttpUserAgentSettings; | 43 class HttpUserAgentSettings; |
| 37 class NetLog; | 44 class NetLog; |
| 38 class NetworkDelegate; | 45 class NetworkDelegate; |
| 39 class NetworkQualityEstimator; | 46 class NetworkQualityEstimator; |
| 40 class SdchManager; | 47 class SdchManager; |
| 41 class ProxyService; | 48 class ProxyService; |
| 42 class URLRequest; | 49 class URLRequest; |
| 43 class URLRequestBackoffManager; | 50 class URLRequestBackoffManager; |
| 44 class URLRequestJobFactory; | 51 class URLRequestJobFactory; |
| 45 class URLRequestThrottlerManager; | 52 class URLRequestThrottlerManager; |
| 46 | 53 |
| 47 // Subclass to provide application-specific context for URLRequest | 54 // Subclass to provide application-specific context for URLRequest |
| 48 // instances. URLRequestContext does not own these member variables, since they | 55 // instances. URLRequestContext does not own these member variables, since they |
| 49 // may be shared with other contexts. URLRequestContextStorage can be used for | 56 // may be shared with other contexts. URLRequestContextStorage can be used for |
| 50 // automatic lifetime management. Most callers should use an existing | 57 // automatic lifetime management. Most callers should use an existing |
| 51 // URLRequestContext rather than creating a new one, as guaranteeing that the | 58 // URLRequestContext rather than creating a new one, as guaranteeing that the |
| 52 // URLRequestContext is destroyed before its members can be difficult. | 59 // URLRequestContext is destroyed before its members can be difficult. |
| 53 class NET_EXPORT URLRequestContext | 60 class NET_EXPORT URLRequestContext |
| 54 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 61 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 62 public base::trace_event::MemoryDumpProvider { |
| 55 public: | 63 public: |
| 56 URLRequestContext(); | 64 URLRequestContext(); |
| 57 virtual ~URLRequestContext(); | 65 ~URLRequestContext() override; |
| 58 | 66 |
| 59 // Copies the state from |other| into this context. | 67 // Copies the state from |other| into this context. |
| 60 void CopyFrom(const URLRequestContext* other); | 68 void CopyFrom(const URLRequestContext* other); |
| 61 | 69 |
| 62 // May return nullptr if this context doesn't have an associated network | 70 // May return nullptr if this context doesn't have an associated network |
| 63 // session. | 71 // session. |
| 64 const HttpNetworkSession::Params* GetNetworkSessionParams() const; | 72 const HttpNetworkSession::Params* GetNetworkSessionParams() const; |
| 65 | 73 |
| 66 std::unique_ptr<URLRequest> CreateRequest( | 74 std::unique_ptr<URLRequest> CreateRequest( |
| 67 const GURL& url, | 75 const GURL& url, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 231 } |
| 224 void set_network_quality_estimator( | 232 void set_network_quality_estimator( |
| 225 NetworkQualityEstimator* network_quality_estimator) { | 233 NetworkQualityEstimator* network_quality_estimator) { |
| 226 network_quality_estimator_ = network_quality_estimator; | 234 network_quality_estimator_ = network_quality_estimator; |
| 227 } | 235 } |
| 228 | 236 |
| 229 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } | 237 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } |
| 230 | 238 |
| 231 bool enable_brotli() const { return enable_brotli_; } | 239 bool enable_brotli() const { return enable_brotli_; } |
| 232 | 240 |
| 241 // Sets a name for this URLRequestContext. Currently the name is used in |
| 242 // MemoryDumpProvier to annotate memory usage. The name does not need to be |
| 243 // unique. |
| 244 void set_name(const std::string& name) { name_ = name; } |
| 245 |
| 246 // MemoryDumpProvider implementation: |
| 247 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 248 base::trace_event::ProcessMemoryDump* pmd) override; |
| 249 |
| 233 private: | 250 private: |
| 234 // --------------------------------------------------------------------------- | 251 // --------------------------------------------------------------------------- |
| 235 // Important: When adding any new members below, consider whether they need to | 252 // Important: When adding any new members below, consider whether they need to |
| 236 // be added to CopyFrom. | 253 // be added to CopyFrom. |
| 237 // --------------------------------------------------------------------------- | 254 // --------------------------------------------------------------------------- |
| 238 | 255 |
| 239 // Ownership for these members are not defined here. Clients should either | 256 // Ownership for these members are not defined here. Clients should either |
| 240 // provide storage elsewhere or have a subclass take ownership. | 257 // provide storage elsewhere or have a subclass take ownership. |
| 241 NetLog* net_log_; | 258 NetLog* net_log_; |
| 242 HostResolver* host_resolver_; | 259 HostResolver* host_resolver_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 262 // --------------------------------------------------------------------------- | 279 // --------------------------------------------------------------------------- |
| 263 // Important: When adding any new members below, consider whether they need to | 280 // Important: When adding any new members below, consider whether they need to |
| 264 // be added to CopyFrom. | 281 // be added to CopyFrom. |
| 265 // --------------------------------------------------------------------------- | 282 // --------------------------------------------------------------------------- |
| 266 | 283 |
| 267 std::unique_ptr<std::set<const URLRequest*>> url_requests_; | 284 std::unique_ptr<std::set<const URLRequest*>> url_requests_; |
| 268 | 285 |
| 269 // Enables Brotli Content-Encoding support. | 286 // Enables Brotli Content-Encoding support. |
| 270 bool enable_brotli_; | 287 bool enable_brotli_; |
| 271 | 288 |
| 289 // An optional name which can be set to describe this URLRequestContext. |
| 290 // Used in MemoryDumpProvier to annotate memory usage. The name does not need |
| 291 // to be unique. |
| 292 std::string name_; |
| 293 |
| 272 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 294 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
| 273 }; | 295 }; |
| 274 | 296 |
| 275 } // namespace net | 297 } // namespace net |
| 276 | 298 |
| 277 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 299 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |