| 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 "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 21 #include "net/http/http_network_session.h" | 21 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_server_properties.h" | 22 #include "net/http/http_server_properties.h" |
| 23 #include "net/http/transport_security_state.h" | 23 #include "net/http/transport_security_state.h" |
| 24 #include "net/ssl/ssl_config_service.h" | 24 #include "net/ssl/ssl_config_service.h" |
| 25 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
| 26 | 26 |
| 27 #include "base/trace_event/memory_dump_provider.h" |
| 28 |
| 27 namespace net { | 29 namespace net { |
| 28 class CertVerifier; | 30 class CertVerifier; |
| 29 class ChannelIDService; | 31 class ChannelIDService; |
| 30 class CookieStore; | 32 class CookieStore; |
| 31 class CTPolicyEnforcer; | 33 class CTPolicyEnforcer; |
| 32 class CTVerifier; | 34 class CTVerifier; |
| 33 class HostResolver; | 35 class HostResolver; |
| 34 class HttpAuthHandlerFactory; | 36 class HttpAuthHandlerFactory; |
| 35 class HttpTransactionFactory; | 37 class HttpTransactionFactory; |
| 36 class HttpUserAgentSettings; | 38 class HttpUserAgentSettings; |
| 37 class NetLog; | 39 class NetLog; |
| 38 class NetworkDelegate; | 40 class NetworkDelegate; |
| 39 class NetworkQualityEstimator; | 41 class NetworkQualityEstimator; |
| 40 class SdchManager; | 42 class SdchManager; |
| 41 class ProxyService; | 43 class ProxyService; |
| 42 class URLRequest; | 44 class URLRequest; |
| 43 class URLRequestBackoffManager; | 45 class URLRequestBackoffManager; |
| 44 class URLRequestJobFactory; | 46 class URLRequestJobFactory; |
| 45 class URLRequestThrottlerManager; | 47 class URLRequestThrottlerManager; |
| 46 | 48 |
| 47 // Subclass to provide application-specific context for URLRequest | 49 // Subclass to provide application-specific context for URLRequest |
| 48 // instances. URLRequestContext does not own these member variables, since they | 50 // instances. URLRequestContext does not own these member variables, since they |
| 49 // may be shared with other contexts. URLRequestContextStorage can be used for | 51 // may be shared with other contexts. URLRequestContextStorage can be used for |
| 50 // automatic lifetime management. Most callers should use an existing | 52 // automatic lifetime management. Most callers should use an existing |
| 51 // URLRequestContext rather than creating a new one, as guaranteeing that the | 53 // URLRequestContext rather than creating a new one, as guaranteeing that the |
| 52 // URLRequestContext is destroyed before its members can be difficult. | 54 // URLRequestContext is destroyed before its members can be difficult. |
| 53 class NET_EXPORT URLRequestContext | 55 class NET_EXPORT URLRequestContext |
| 54 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 56 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 57 public base::trace_event::MemoryDumpProvider { |
| 55 public: | 58 public: |
| 56 URLRequestContext(); | 59 URLRequestContext(); |
| 57 virtual ~URLRequestContext(); | 60 ~URLRequestContext() override; |
| 58 | 61 |
| 59 // Copies the state from |other| into this context. | 62 // Copies the state from |other| into this context. |
| 60 void CopyFrom(const URLRequestContext* other); | 63 void CopyFrom(const URLRequestContext* other); |
| 61 | 64 |
| 62 // May return nullptr if this context doesn't have an associated network | 65 // May return nullptr if this context doesn't have an associated network |
| 63 // session. | 66 // session. |
| 64 const HttpNetworkSession::Params* GetNetworkSessionParams() const; | 67 const HttpNetworkSession::Params* GetNetworkSessionParams() const; |
| 65 | 68 |
| 66 std::unique_ptr<URLRequest> CreateRequest( | 69 std::unique_ptr<URLRequest> CreateRequest( |
| 67 const GURL& url, | 70 const GURL& url, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return http_auth_handler_factory_; | 124 return http_auth_handler_factory_; |
| 122 } | 125 } |
| 123 void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { | 126 void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { |
| 124 http_auth_handler_factory_ = factory; | 127 http_auth_handler_factory_ = factory; |
| 125 } | 128 } |
| 126 | 129 |
| 127 // Gets the http transaction factory for this context. | 130 // Gets the http transaction factory for this context. |
| 128 HttpTransactionFactory* http_transaction_factory() const { | 131 HttpTransactionFactory* http_transaction_factory() const { |
| 129 return http_transaction_factory_; | 132 return http_transaction_factory_; |
| 130 } | 133 } |
| 134 |
| 131 void set_http_transaction_factory(HttpTransactionFactory* factory) { | 135 void set_http_transaction_factory(HttpTransactionFactory* factory) { |
| 132 http_transaction_factory_ = factory; | 136 http_transaction_factory_ = factory; |
| 133 } | 137 } |
| 134 | 138 |
| 135 void set_network_delegate(NetworkDelegate* network_delegate) { | 139 void set_network_delegate(NetworkDelegate* network_delegate) { |
| 136 network_delegate_ = network_delegate; | 140 network_delegate_ = network_delegate; |
| 137 } | 141 } |
| 138 NetworkDelegate* network_delegate() const { return network_delegate_; } | 142 NetworkDelegate* network_delegate() const { return network_delegate_; } |
| 139 | 143 |
| 140 void set_http_server_properties( | 144 void set_http_server_properties( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 227 } |
| 224 void set_network_quality_estimator( | 228 void set_network_quality_estimator( |
| 225 NetworkQualityEstimator* network_quality_estimator) { | 229 NetworkQualityEstimator* network_quality_estimator) { |
| 226 network_quality_estimator_ = network_quality_estimator; | 230 network_quality_estimator_ = network_quality_estimator; |
| 227 } | 231 } |
| 228 | 232 |
| 229 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } | 233 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } |
| 230 | 234 |
| 231 bool enable_brotli() const { return enable_brotli_; } | 235 bool enable_brotli() const { return enable_brotli_; } |
| 232 | 236 |
| 237 void set_name_string(const std::string& name_string){ |
| 238 name_string_ = name_string; |
| 239 } |
| 240 |
| 241 // MemoryDumpProvider implementation: |
| 242 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 243 base::trace_event::ProcessMemoryDump* pmd) override; |
| 244 |
| 233 private: | 245 private: |
| 234 // --------------------------------------------------------------------------- | 246 // --------------------------------------------------------------------------- |
| 235 // Important: When adding any new members below, consider whether they need to | 247 // Important: When adding any new members below, consider whether they need to |
| 236 // be added to CopyFrom. | 248 // be added to CopyFrom. |
| 237 // --------------------------------------------------------------------------- | 249 // --------------------------------------------------------------------------- |
| 238 | 250 |
| 239 // Ownership for these members are not defined here. Clients should either | 251 // Ownership for these members are not defined here. Clients should either |
| 240 // provide storage elsewhere or have a subclass take ownership. | 252 // provide storage elsewhere or have a subclass take ownership. |
| 241 NetLog* net_log_; | 253 NetLog* net_log_; |
| 242 HostResolver* host_resolver_; | 254 HostResolver* host_resolver_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 262 // --------------------------------------------------------------------------- | 274 // --------------------------------------------------------------------------- |
| 263 // Important: When adding any new members below, consider whether they need to | 275 // Important: When adding any new members below, consider whether they need to |
| 264 // be added to CopyFrom. | 276 // be added to CopyFrom. |
| 265 // --------------------------------------------------------------------------- | 277 // --------------------------------------------------------------------------- |
| 266 | 278 |
| 267 std::unique_ptr<std::set<const URLRequest*>> url_requests_; | 279 std::unique_ptr<std::set<const URLRequest*>> url_requests_; |
| 268 | 280 |
| 269 // Enables Brotli Content-Encoding support. | 281 // Enables Brotli Content-Encoding support. |
| 270 bool enable_brotli_; | 282 bool enable_brotli_; |
| 271 | 283 |
| 284 std::string name_string_; |
| 285 |
| 272 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 286 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
| 273 }; | 287 }; |
| 274 | 288 |
| 275 } // namespace net | 289 } // namespace net |
| 276 | 290 |
| 277 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 291 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |