| 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/sequence_checker.h" |
| 19 #include "base/trace_event/memory_dump_provider.h" | 19 #include "base/trace_event/memory_dump_provider.h" |
| 20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
| 21 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 22 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
| 23 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
| 24 #include "net/http/transport_security_state.h" | 24 #include "net/http/transport_security_state.h" |
| 25 #include "net/ssl/ssl_config_service.h" | 25 #include "net/ssl/ssl_config_service.h" |
| 26 #include "net/traffic_annotation/network_traffic_annotation.h" | 26 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 28 | 28 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 53 class URLRequestJobFactory; | 53 class URLRequestJobFactory; |
| 54 class URLRequestThrottlerManager; | 54 class URLRequestThrottlerManager; |
| 55 | 55 |
| 56 // Subclass to provide application-specific context for URLRequest | 56 // Subclass to provide application-specific context for URLRequest |
| 57 // instances. URLRequestContext does not own these member variables, since they | 57 // instances. URLRequestContext does not own these member variables, since they |
| 58 // may be shared with other contexts. URLRequestContextStorage can be used for | 58 // may be shared with other contexts. URLRequestContextStorage can be used for |
| 59 // automatic lifetime management. Most callers should use an existing | 59 // automatic lifetime management. Most callers should use an existing |
| 60 // URLRequestContext rather than creating a new one, as guaranteeing that the | 60 // URLRequestContext rather than creating a new one, as guaranteeing that the |
| 61 // URLRequestContext is destroyed before its members can be difficult. | 61 // URLRequestContext is destroyed before its members can be difficult. |
| 62 class NET_EXPORT URLRequestContext | 62 class NET_EXPORT URLRequestContext |
| 63 : NON_EXPORTED_BASE(public base::NonThreadSafe), | 63 : public base::trace_event::MemoryDumpProvider { |
| 64 public base::trace_event::MemoryDumpProvider { | |
| 65 public: | 64 public: |
| 66 URLRequestContext(); | 65 URLRequestContext(); |
| 67 ~URLRequestContext() override; | 66 ~URLRequestContext() override; |
| 68 | 67 |
| 69 // Copies the state from |other| into this context. | 68 // Copies the state from |other| into this context. |
| 70 void CopyFrom(const URLRequestContext* other); | 69 void CopyFrom(const URLRequestContext* other); |
| 71 | 70 |
| 72 // May return nullptr if this context doesn't have an associated network | 71 // May return nullptr if this context doesn't have an associated network |
| 73 // session. | 72 // session. |
| 74 const HttpNetworkSession::Params* GetNetworkSessionParams() const; | 73 const HttpNetworkSession::Params* GetNetworkSessionParams() const; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 273 |
| 275 // Sets a name for this URLRequestContext. Currently the name is used in | 274 // Sets a name for this URLRequestContext. Currently the name is used in |
| 276 // MemoryDumpProvier to annotate memory usage. The name does not need to be | 275 // MemoryDumpProvier to annotate memory usage. The name does not need to be |
| 277 // unique. | 276 // unique. |
| 278 void set_name(const char* name) { name_ = name; } | 277 void set_name(const char* name) { name_ = name; } |
| 279 | 278 |
| 280 // MemoryDumpProvider implementation: | 279 // MemoryDumpProvider implementation: |
| 281 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 280 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 282 base::trace_event::ProcessMemoryDump* pmd) override; | 281 base::trace_event::ProcessMemoryDump* pmd) override; |
| 283 | 282 |
| 283 void AssertCalledOnValidSequence() const { |
| 284 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 285 } |
| 286 |
| 284 private: | 287 private: |
| 285 // --------------------------------------------------------------------------- | 288 // --------------------------------------------------------------------------- |
| 286 // Important: When adding any new members below, consider whether they need to | 289 // Important: When adding any new members below, consider whether they need to |
| 287 // be added to CopyFrom. | 290 // be added to CopyFrom. |
| 288 // --------------------------------------------------------------------------- | 291 // --------------------------------------------------------------------------- |
| 289 | 292 |
| 290 // Ownership for these members are not defined here. Clients should either | 293 // Ownership for these members are not defined here. Clients should either |
| 291 // provide storage elsewhere or have a subclass take ownership. | 294 // provide storage elsewhere or have a subclass take ownership. |
| 292 NetLog* net_log_; | 295 NetLog* net_log_; |
| 293 HostResolver* host_resolver_; | 296 HostResolver* host_resolver_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 329 |
| 327 // An optional name which can be set to describe this URLRequestContext. | 330 // An optional name which can be set to describe this URLRequestContext. |
| 328 // Used in MemoryDumpProvier to annotate memory usage. The name does not need | 331 // Used in MemoryDumpProvier to annotate memory usage. The name does not need |
| 329 // to be unique. | 332 // to be unique. |
| 330 const char* name_; | 333 const char* name_; |
| 331 | 334 |
| 332 // The largest number of outstanding URLRequests that have been created by | 335 // The largest number of outstanding URLRequests that have been created by |
| 333 // |this| and are not yet destroyed. This doesn't need to be in CopyFrom. | 336 // |this| and are not yet destroyed. This doesn't need to be in CopyFrom. |
| 334 mutable size_t largest_outstanding_requests_count_seen_; | 337 mutable size_t largest_outstanding_requests_count_seen_; |
| 335 | 338 |
| 339 SEQUENCE_CHECKER(sequence_checker_); |
| 340 |
| 336 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 341 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
| 337 }; | 342 }; |
| 338 | 343 |
| 339 } // namespace net | 344 } // namespace net |
| 340 | 345 |
| 341 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 346 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |