| 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 useful when processing resource requests. | 6 // that's useful when processing resource requests. |
| 7 // The class is reference-counted so that it can be cleaned up after any | 7 // The class is reference-counted so that it can be cleaned up after any |
| 8 // requests that are using it have been completed. | 8 // requests that are using it have been completed. |
| 9 | 9 |
| 10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class ProxyService; | 37 class ProxyService; |
| 38 class URLRequest; | 38 class URLRequest; |
| 39 class URLRequestJobFactory; | 39 class URLRequestJobFactory; |
| 40 class URLRequestThrottlerManager; | 40 class URLRequestThrottlerManager; |
| 41 | 41 |
| 42 // Subclass to provide application-specific context for URLRequest | 42 // Subclass to provide application-specific context for URLRequest |
| 43 // instances. Note that URLRequestContext typically does not provide storage for | 43 // instances. Note that URLRequestContext typically does not provide storage for |
| 44 // these member variables, since they may be shared. For the ones that aren't | 44 // these member variables, since they may be shared. For the ones that aren't |
| 45 // shared, URLRequestContextStorage can be helpful in defining their storage. | 45 // shared, URLRequestContextStorage can be helpful in defining their storage. |
| 46 class NET_EXPORT URLRequestContext | 46 class NET_EXPORT URLRequestContext |
| 47 : public base::RefCountedThreadSafe<URLRequestContext>, | 47 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 48 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 49 public: | 48 public: |
| 50 URLRequestContext(); | 49 URLRequestContext(); |
| 51 | 50 virtual ~URLRequestContext(); |
| 52 base::WeakPtr<URLRequestContext> GetWeakPtr() { | |
| 53 return weak_factory_.GetWeakPtr(); | |
| 54 } | |
| 55 | 51 |
| 56 // Copies the state from |other| into this context. | 52 // Copies the state from |other| into this context. |
| 57 void CopyFrom(URLRequestContext* other); | 53 void CopyFrom(URLRequestContext* other); |
| 58 | 54 |
| 59 NetLog* net_log() const { | 55 NetLog* net_log() const { |
| 60 return net_log_; | 56 return net_log_; |
| 61 } | 57 } |
| 62 | 58 |
| 63 void set_net_log(NetLog* net_log) { | 59 void set_net_log(NetLog* net_log) { |
| 64 net_log_ = net_log; | 60 net_log_ = net_log; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 100 } |
| 105 | 101 |
| 106 // Get the ssl config service for this context. | 102 // Get the ssl config service for this context. |
| 107 SSLConfigService* ssl_config_service() const { return ssl_config_service_; } | 103 SSLConfigService* ssl_config_service() const { return ssl_config_service_; } |
| 108 void set_ssl_config_service(SSLConfigService* service) { | 104 void set_ssl_config_service(SSLConfigService* service) { |
| 109 ssl_config_service_ = service; | 105 ssl_config_service_ = service; |
| 110 } | 106 } |
| 111 | 107 |
| 112 // Gets the HTTP Authentication Handler Factory for this context. | 108 // Gets the HTTP Authentication Handler Factory for this context. |
| 113 // The factory is only valid for the lifetime of this URLRequestContext | 109 // The factory is only valid for the lifetime of this URLRequestContext |
| 114 HttpAuthHandlerFactory* http_auth_handler_factory() { | 110 HttpAuthHandlerFactory* http_auth_handler_factory() const { |
| 115 return http_auth_handler_factory_; | 111 return http_auth_handler_factory_; |
| 116 } | 112 } |
| 117 void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { | 113 void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { |
| 118 http_auth_handler_factory_ = factory; | 114 http_auth_handler_factory_ = factory; |
| 119 } | 115 } |
| 120 | 116 |
| 121 // Gets the http transaction factory for this context. | 117 // Gets the http transaction factory for this context. |
| 122 HttpTransactionFactory* http_transaction_factory() const { | 118 HttpTransactionFactory* http_transaction_factory() const { |
| 123 return http_transaction_factory_; | 119 return http_transaction_factory_; |
| 124 } | 120 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 197 } |
| 202 | 198 |
| 203 // Gets the URLRequest objects that hold a reference to this | 199 // Gets the URLRequest objects that hold a reference to this |
| 204 // URLRequestContext. | 200 // URLRequestContext. |
| 205 std::set<const URLRequest*>* url_requests() const { | 201 std::set<const URLRequest*>* url_requests() const { |
| 206 return url_requests_.get(); | 202 return url_requests_.get(); |
| 207 } | 203 } |
| 208 | 204 |
| 209 void AssertNoURLRequests() const; | 205 void AssertNoURLRequests() const; |
| 210 | 206 |
| 211 protected: | |
| 212 friend class base::RefCountedThreadSafe<URLRequestContext>; | |
| 213 | |
| 214 virtual ~URLRequestContext(); | |
| 215 | |
| 216 private: | 207 private: |
| 217 base::WeakPtrFactory<URLRequestContext> weak_factory_; | |
| 218 | |
| 219 // --------------------------------------------------------------------------- | 208 // --------------------------------------------------------------------------- |
| 220 // Important: When adding any new members below, consider whether they need to | 209 // Important: When adding any new members below, consider whether they need to |
| 221 // be added to CopyFrom. | 210 // be added to CopyFrom. |
| 222 // --------------------------------------------------------------------------- | 211 // --------------------------------------------------------------------------- |
| 223 | 212 |
| 224 // Ownership for these members are not defined here. Clients should either | 213 // Ownership for these members are not defined here. Clients should either |
| 225 // provide storage elsewhere or have a subclass take ownership. | 214 // provide storage elsewhere or have a subclass take ownership. |
| 226 NetLog* net_log_; | 215 NetLog* net_log_; |
| 227 HostResolver* host_resolver_; | 216 HostResolver* host_resolver_; |
| 228 CertVerifier* cert_verifier_; | 217 CertVerifier* cert_verifier_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 253 // --------------------------------------------------------------------------- | 242 // --------------------------------------------------------------------------- |
| 254 | 243 |
| 255 scoped_ptr<std::set<const URLRequest*> > url_requests_; | 244 scoped_ptr<std::set<const URLRequest*> > url_requests_; |
| 256 | 245 |
| 257 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 246 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
| 258 }; | 247 }; |
| 259 | 248 |
| 260 } // namespace net | 249 } // namespace net |
| 261 | 250 |
| 262 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 251 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |