Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Side by Side Diff: net/url_request/url_request_context.h

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for chrome_frame_net_tests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_
11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
12 12
13 #include <set> 13 #include <set>
14 #include <string>
14 15
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
19 #include "net/base/net_export.h" 20 #include "net/base/net_export.h"
20 #include "net/base/net_log.h" 21 #include "net/base/net_log.h"
21 #include "net/base/ssl_config_service.h" 22 #include "net/base/ssl_config_service.h"
22 #include "net/base/transport_security_state.h" 23 #include "net/base/transport_security_state.h"
23 #include "net/http/http_network_session.h" 24 #include "net/http/http_network_session.h"
24 #include "net/http/http_server_properties.h" 25 #include "net/http/http_server_properties.h"
25 #include "net/ftp/ftp_auth_cache.h" 26 #include "net/ftp/ftp_auth_cache.h"
26 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
27 28
28 namespace net { 29 namespace net {
29 class CertVerifier; 30 class CertVerifier;
30 class CookieStore; 31 class CookieStore;
31 class FraudulentCertificateReporter; 32 class FraudulentCertificateReporter;
32 class FtpTransactionFactory; 33 class FtpTransactionFactory;
33 class HostResolver; 34 class HostResolver;
34 class HttpAuthHandlerFactory; 35 class HttpAuthHandlerFactory;
35 class HttpTransactionFactory; 36 class HttpTransactionFactory;
37 class HttpUserAgentSettings;
36 class NetworkDelegate; 38 class NetworkDelegate;
37 class ServerBoundCertService; 39 class ServerBoundCertService;
38 class ProxyService; 40 class ProxyService;
39 class URLRequest; 41 class URLRequest;
40 class URLRequestJobFactory; 42 class URLRequestJobFactory;
41 class URLRequestThrottlerManager; 43 class URLRequestThrottlerManager;
42 44
43 // Subclass to provide application-specific context for URLRequest 45 // Subclass to provide application-specific context for URLRequest
44 // instances. Note that URLRequestContext typically does not provide storage for 46 // 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 47 // 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
165 167
166 // Gets the FTP authentication cache for this context. 168 // Gets the FTP authentication cache for this context.
167 FtpAuthCache* ftp_auth_cache() const { 169 FtpAuthCache* ftp_auth_cache() const {
168 #if !defined(DISABLE_FTP_SUPPORT) 170 #if !defined(DISABLE_FTP_SUPPORT)
169 return ftp_auth_cache_.get(); 171 return ftp_auth_cache_.get();
170 #else 172 #else
171 return NULL; 173 return NULL;
172 #endif 174 #endif
173 } 175 }
174 176
177 // ---------------------------------------------------------------------------
178 // Legacy accessors that delegate to http_user_agent_settings_.
179 // TODO(pauljensen): Remove after all clients are updated to directly access
180 // http_user_agent_settings_.
175 // Gets the value of 'Accept-Charset' header field. 181 // Gets the value of 'Accept-Charset' header field.
176 const std::string& accept_charset() const { return accept_charset_; } 182 std::string GetAcceptCharset() 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. 183 // Gets the value of 'Accept-Language' header field.
182 const std::string& accept_language() const { return accept_language_; } 184 std::string GetAcceptLanguage() 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 185 // 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 186 // GURL()) to get the default UA string.
189 // method to provide a UA string. 187 std::string GetUserAgent(const GURL& url) const;
190 virtual const std::string& GetUserAgent(const GURL& url) const; 188 // ---------------------------------------------------------------------------
191 189
192 const URLRequestJobFactory* job_factory() const { return job_factory_; } 190 const URLRequestJobFactory* job_factory() const { return job_factory_; }
193 void set_job_factory(const URLRequestJobFactory* job_factory) { 191 void set_job_factory(const URLRequestJobFactory* job_factory) {
194 job_factory_ = job_factory; 192 job_factory_ = job_factory;
195 } 193 }
196 194
197 // May be NULL. 195 // May be NULL.
198 URLRequestThrottlerManager* throttler_manager() const { 196 URLRequestThrottlerManager* throttler_manager() const {
199 return throttler_manager_; 197 return throttler_manager_;
200 } 198 }
201 void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) { 199 void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) {
202 throttler_manager_ = throttler_manager; 200 throttler_manager_ = throttler_manager;
203 } 201 }
204 202
205 // Gets the URLRequest objects that hold a reference to this 203 // Gets the URLRequest objects that hold a reference to this
206 // URLRequestContext. 204 // URLRequestContext.
207 std::set<const URLRequest*>* url_requests() const { 205 std::set<const URLRequest*>* url_requests() const {
208 return url_requests_.get(); 206 return url_requests_.get();
209 } 207 }
210 208
211 void AssertNoURLRequests() const; 209 void AssertNoURLRequests() const;
212 210
211 // Get the underlying |HttpUserAgentSettings| implementation that provides
212 // the HTTP Accept-Language, Accept-Charset and User-Agent header values.
213 const HttpUserAgentSettings* http_user_agent_settings() const {
214 return http_user_agent_settings_;
215 }
216 void set_http_user_agent_settings(
217 HttpUserAgentSettings* http_user_agent_settings) {
218 http_user_agent_settings_ = http_user_agent_settings;
219 }
220
213 private: 221 private:
214 // --------------------------------------------------------------------------- 222 // ---------------------------------------------------------------------------
215 // Important: When adding any new members below, consider whether they need to 223 // Important: When adding any new members below, consider whether they need to
216 // be added to CopyFrom. 224 // be added to CopyFrom.
217 // --------------------------------------------------------------------------- 225 // ---------------------------------------------------------------------------
218 226
219 // Ownership for these members are not defined here. Clients should either 227 // Ownership for these members are not defined here. Clients should either
220 // provide storage elsewhere or have a subclass take ownership. 228 // provide storage elsewhere or have a subclass take ownership.
221 NetLog* net_log_; 229 NetLog* net_log_;
222 HostResolver* host_resolver_; 230 HostResolver* host_resolver_;
223 CertVerifier* cert_verifier_; 231 CertVerifier* cert_verifier_;
224 ServerBoundCertService* server_bound_cert_service_; 232 ServerBoundCertService* server_bound_cert_service_;
225 FraudulentCertificateReporter* fraudulent_certificate_reporter_; 233 FraudulentCertificateReporter* fraudulent_certificate_reporter_;
226 HttpAuthHandlerFactory* http_auth_handler_factory_; 234 HttpAuthHandlerFactory* http_auth_handler_factory_;
227 ProxyService* proxy_service_; 235 ProxyService* proxy_service_;
228 scoped_refptr<SSLConfigService> ssl_config_service_; 236 scoped_refptr<SSLConfigService> ssl_config_service_;
229 NetworkDelegate* network_delegate_; 237 NetworkDelegate* network_delegate_;
230 HttpServerProperties* http_server_properties_; 238 HttpServerProperties* http_server_properties_;
239 HttpUserAgentSettings* http_user_agent_settings_;
231 scoped_refptr<CookieStore> cookie_store_; 240 scoped_refptr<CookieStore> cookie_store_;
232 TransportSecurityState* transport_security_state_; 241 TransportSecurityState* transport_security_state_;
233 #if !defined(DISABLE_FTP_SUPPORT) 242 #if !defined(DISABLE_FTP_SUPPORT)
234 scoped_ptr<FtpAuthCache> ftp_auth_cache_; 243 scoped_ptr<FtpAuthCache> ftp_auth_cache_;
235 #endif 244 #endif
236 std::string accept_language_;
237 std::string accept_charset_;
238 // The charset of the referrer where this request comes from. It's not 245 // The charset of the referrer where this request comes from. It's not
239 // used in communication with a server but is used to construct a suggested 246 // used in communication with a server but is used to construct a suggested
240 // filename for file download. 247 // filename for file download.
241 HttpTransactionFactory* http_transaction_factory_; 248 HttpTransactionFactory* http_transaction_factory_;
242 FtpTransactionFactory* ftp_transaction_factory_; 249 FtpTransactionFactory* ftp_transaction_factory_;
243 const URLRequestJobFactory* job_factory_; 250 const URLRequestJobFactory* job_factory_;
244 URLRequestThrottlerManager* throttler_manager_; 251 URLRequestThrottlerManager* throttler_manager_;
245 252
246 // --------------------------------------------------------------------------- 253 // ---------------------------------------------------------------------------
247 // Important: When adding any new members below, consider whether they need to 254 // Important: When adding any new members below, consider whether they need to
248 // be added to CopyFrom. 255 // be added to CopyFrom.
249 // --------------------------------------------------------------------------- 256 // ---------------------------------------------------------------------------
250 257
251 scoped_ptr<std::set<const URLRequest*> > url_requests_; 258 scoped_ptr<std::set<const URLRequest*> > url_requests_;
252 259
253 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); 260 DISALLOW_COPY_AND_ASSIGN(URLRequestContext);
254 }; 261 };
255 262
256 } // namespace net 263 } // namespace net
257 264
258 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 265 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
OLDNEW
« no previous file with comments | « net/url_request/static_http_user_agent_settings.cc ('k') | net/url_request/url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698