Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 class CertVerifier; | 29 class CertVerifier; |
| 30 class CookieStore; | 30 class CookieStore; |
| 31 class FraudulentCertificateReporter; | 31 class FraudulentCertificateReporter; |
| 32 class FtpTransactionFactory; | 32 class FtpTransactionFactory; |
| 33 class HostResolver; | 33 class HostResolver; |
| 34 class HttpAuthHandlerFactory; | 34 class HttpAuthHandlerFactory; |
| 35 class HttpTransactionFactory; | 35 class HttpTransactionFactory; |
| 36 class HttpUserAgentSettings; | |
| 36 class NetworkDelegate; | 37 class NetworkDelegate; |
| 37 class ServerBoundCertService; | 38 class ServerBoundCertService; |
| 38 class ProxyService; | 39 class ProxyService; |
| 39 class URLRequest; | 40 class URLRequest; |
| 40 class URLRequestJobFactory; | 41 class URLRequestJobFactory; |
| 41 class URLRequestThrottlerManager; | 42 class URLRequestThrottlerManager; |
| 42 | 43 |
| 43 // Subclass to provide application-specific context for URLRequest | 44 // Subclass to provide application-specific context for URLRequest |
| 44 // instances. Note that URLRequestContext typically does not provide storage for | 45 // instances. Note that URLRequestContext typically does not provide storage for |
| 45 // these member variables, since they may be shared. For the ones that aren't | 46 // these member variables, since they may be shared. For the ones that aren't |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 166 |
| 166 // Gets the FTP authentication cache for this context. | 167 // Gets the FTP authentication cache for this context. |
| 167 FtpAuthCache* ftp_auth_cache() const { | 168 FtpAuthCache* ftp_auth_cache() const { |
| 168 #if !defined(DISABLE_FTP_SUPPORT) | 169 #if !defined(DISABLE_FTP_SUPPORT) |
| 169 return ftp_auth_cache_.get(); | 170 return ftp_auth_cache_.get(); |
| 170 #else | 171 #else |
| 171 return NULL; | 172 return NULL; |
| 172 #endif | 173 #endif |
| 173 } | 174 } |
| 174 | 175 |
| 176 // --------------------------------------------------------------------------- | |
| 177 // Legacy accessors that delegate to http_user_agent_settings_. | |
| 178 // TODO(pauljensen): Remove after all clients are updated to directly access | |
| 179 // http_user_agent_settings_. | |
| 175 // Gets the value of 'Accept-Charset' header field. | 180 // Gets the value of 'Accept-Charset' header field. |
| 176 const std::string& accept_charset() const { return accept_charset_; } | 181 const std::string& accept_charset() const; |
| 177 void set_accept_charset(const std::string& accept_charset) { | |
| 178 accept_charset_ = accept_charset; | |
| 179 } | |
| 180 | |
| 181 // Gets the value of 'Accept-Language' header field. | 182 // Gets the value of 'Accept-Language' header field. |
| 182 const std::string& accept_language() const { return accept_language_; } | 183 const std::string& accept_language() const; |
| 183 void set_accept_language(const std::string& accept_language) { | |
| 184 accept_language_ = accept_language; | |
| 185 } | |
| 186 | |
| 187 // Gets the UA string to use for the given URL. Pass an invalid URL (such as | 184 // Gets the UA string to use for the given URL. Pass an invalid URL (such as |
| 188 // GURL()) to get the default UA string. Subclasses should override this | 185 // GURL()) to get the default UA string. |
| 189 // method to provide a UA string. | 186 const std::string& GetUserAgent(const GURL& url) const; |
| 190 virtual const std::string& GetUserAgent(const GURL& url) const; | 187 // --------------------------------------------------------------------------- |
| 191 | 188 |
| 192 // In general, referrer_charset is not known when URLRequestContext is | 189 // In general, referrer_charset is not known when URLRequestContext is |
| 193 // constructed. So, we need a setter. | 190 // constructed. So, we need a setter. |
| 194 const std::string& referrer_charset() const { return referrer_charset_; } | 191 const std::string& referrer_charset() const { return referrer_charset_; } |
| 195 void set_referrer_charset(const std::string& charset) { | 192 void set_referrer_charset(const std::string& charset) { |
| 196 referrer_charset_ = charset; | 193 referrer_charset_ = charset; |
| 197 } | 194 } |
| 198 | 195 |
| 199 const URLRequestJobFactory* job_factory() const { return job_factory_; } | 196 const URLRequestJobFactory* job_factory() const { return job_factory_; } |
| 200 void set_job_factory(const URLRequestJobFactory* job_factory) { | 197 void set_job_factory(const URLRequestJobFactory* job_factory) { |
| 201 job_factory_ = job_factory; | 198 job_factory_ = job_factory; |
| 202 } | 199 } |
| 203 | 200 |
| 204 // May be NULL. | 201 // May be NULL. |
| 205 URLRequestThrottlerManager* throttler_manager() const { | 202 URLRequestThrottlerManager* throttler_manager() const { |
| 206 return throttler_manager_; | 203 return throttler_manager_; |
| 207 } | 204 } |
| 208 void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) { | 205 void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) { |
| 209 throttler_manager_ = throttler_manager; | 206 throttler_manager_ = throttler_manager; |
| 210 } | 207 } |
| 211 | 208 |
| 212 // Gets the URLRequest objects that hold a reference to this | 209 // Gets the URLRequest objects that hold a reference to this |
| 213 // URLRequestContext. | 210 // URLRequestContext. |
| 214 std::set<const URLRequest*>* url_requests() const { | 211 std::set<const URLRequest*>* url_requests() const { |
| 215 return url_requests_.get(); | 212 return url_requests_.get(); |
| 216 } | 213 } |
| 217 | 214 |
| 218 void AssertNoURLRequests() const; | 215 void AssertNoURLRequests() const; |
| 219 | 216 |
| 217 // Set the underlying |HttpUserAgentSettings| implementation that provides | |
| 218 // the HTTP Accept-Language, Accept-Charset and User-Agent header values. | |
| 219 void set_http_user_agent_settings( | |
| 220 HttpUserAgentSettings* http_user_agent_settings) { | |
| 221 http_user_agent_settings_ = http_user_agent_settings; | |
|
mmenke
2012/09/26 16:28:20
nit: Fix indent. HttpUserAgentSettings* should b
| |
| 222 } | |
| 223 | |
| 220 private: | 224 private: |
| 221 // --------------------------------------------------------------------------- | 225 // --------------------------------------------------------------------------- |
| 222 // Important: When adding any new members below, consider whether they need to | 226 // Important: When adding any new members below, consider whether they need to |
| 223 // be added to CopyFrom. | 227 // be added to CopyFrom. |
| 224 // --------------------------------------------------------------------------- | 228 // --------------------------------------------------------------------------- |
| 225 | 229 |
| 226 // Ownership for these members are not defined here. Clients should either | 230 // Ownership for these members are not defined here. Clients should either |
| 227 // provide storage elsewhere or have a subclass take ownership. | 231 // provide storage elsewhere or have a subclass take ownership. |
| 228 NetLog* net_log_; | 232 NetLog* net_log_; |
| 229 HostResolver* host_resolver_; | 233 HostResolver* host_resolver_; |
| 230 CertVerifier* cert_verifier_; | 234 CertVerifier* cert_verifier_; |
| 231 ServerBoundCertService* server_bound_cert_service_; | 235 ServerBoundCertService* server_bound_cert_service_; |
| 232 FraudulentCertificateReporter* fraudulent_certificate_reporter_; | 236 FraudulentCertificateReporter* fraudulent_certificate_reporter_; |
| 233 HttpAuthHandlerFactory* http_auth_handler_factory_; | 237 HttpAuthHandlerFactory* http_auth_handler_factory_; |
| 234 ProxyService* proxy_service_; | 238 ProxyService* proxy_service_; |
| 235 scoped_refptr<SSLConfigService> ssl_config_service_; | 239 scoped_refptr<SSLConfigService> ssl_config_service_; |
| 236 NetworkDelegate* network_delegate_; | 240 NetworkDelegate* network_delegate_; |
| 237 HttpServerProperties* http_server_properties_; | 241 HttpServerProperties* http_server_properties_; |
| 238 scoped_refptr<CookieStore> cookie_store_; | 242 scoped_refptr<CookieStore> cookie_store_; |
| 239 TransportSecurityState* transport_security_state_; | 243 TransportSecurityState* transport_security_state_; |
| 240 #if !defined(DISABLE_FTP_SUPPORT) | 244 #if !defined(DISABLE_FTP_SUPPORT) |
| 241 scoped_ptr<FtpAuthCache> ftp_auth_cache_; | 245 scoped_ptr<FtpAuthCache> ftp_auth_cache_; |
| 242 #endif | 246 #endif |
| 243 std::string accept_language_; | |
| 244 std::string accept_charset_; | |
| 245 // The charset of the referrer where this request comes from. It's not | 247 // The charset of the referrer where this request comes from. It's not |
| 246 // used in communication with a server but is used to construct a suggested | 248 // used in communication with a server but is used to construct a suggested |
| 247 // filename for file download. | 249 // filename for file download. |
| 248 std::string referrer_charset_; | 250 std::string referrer_charset_; |
| 249 HttpTransactionFactory* http_transaction_factory_; | 251 HttpTransactionFactory* http_transaction_factory_; |
| 250 FtpTransactionFactory* ftp_transaction_factory_; | 252 FtpTransactionFactory* ftp_transaction_factory_; |
| 251 const URLRequestJobFactory* job_factory_; | 253 const URLRequestJobFactory* job_factory_; |
| 252 URLRequestThrottlerManager* throttler_manager_; | 254 URLRequestThrottlerManager* throttler_manager_; |
| 255 HttpUserAgentSettings* http_user_agent_settings_; | |
| 253 | 256 |
| 254 // --------------------------------------------------------------------------- | 257 // --------------------------------------------------------------------------- |
| 255 // Important: When adding any new members below, consider whether they need to | 258 // Important: When adding any new members below, consider whether they need to |
| 256 // be added to CopyFrom. | 259 // be added to CopyFrom. |
| 257 // --------------------------------------------------------------------------- | 260 // --------------------------------------------------------------------------- |
| 258 | 261 |
| 259 scoped_ptr<std::set<const URLRequest*> > url_requests_; | 262 scoped_ptr<std::set<const URLRequest*> > url_requests_; |
| 260 | 263 |
| 261 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 264 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
| 262 }; | 265 }; |
| 263 | 266 |
| 264 } // namespace net | 267 } // namespace net |
| 265 | 268 |
| 266 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 269 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |