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

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: add TODO Created 8 years, 2 months 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_
(...skipping 15 matching lines...) Expand all
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
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 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. 182 // Gets the value of 'Accept-Language' header field.
182 const std::string& accept_language() const { return accept_language_; } 183 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 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 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 // Get the underlying |HttpUserAgentSettings| implementation that provides
218 // the HTTP Accept-Language, Accept-Charset and User-Agent header values.
219 HttpUserAgentSettings* http_user_agent_settings() const {
willchan no longer on Chromium 2012/10/24 03:40:10 Can we return const HttpUserAgentSettings*, or do
pauljensen 2012/10/24 19:19:00 If the getters are not const, then this cannot be
220 return http_user_agent_settings_;
221 }
222 void set_http_user_agent_settings(
223 HttpUserAgentSettings* http_user_agent_settings) {
224 http_user_agent_settings_ = http_user_agent_settings;
225 }
226
220 private: 227 private:
221 // --------------------------------------------------------------------------- 228 // ---------------------------------------------------------------------------
222 // Important: When adding any new members below, consider whether they need to 229 // Important: When adding any new members below, consider whether they need to
223 // be added to CopyFrom. 230 // be added to CopyFrom.
224 // --------------------------------------------------------------------------- 231 // ---------------------------------------------------------------------------
225 232
226 // Ownership for these members are not defined here. Clients should either 233 // Ownership for these members are not defined here. Clients should either
227 // provide storage elsewhere or have a subclass take ownership. 234 // provide storage elsewhere or have a subclass take ownership.
228 NetLog* net_log_; 235 NetLog* net_log_;
229 HostResolver* host_resolver_; 236 HostResolver* host_resolver_;
230 CertVerifier* cert_verifier_; 237 CertVerifier* cert_verifier_;
231 ServerBoundCertService* server_bound_cert_service_; 238 ServerBoundCertService* server_bound_cert_service_;
232 FraudulentCertificateReporter* fraudulent_certificate_reporter_; 239 FraudulentCertificateReporter* fraudulent_certificate_reporter_;
233 HttpAuthHandlerFactory* http_auth_handler_factory_; 240 HttpAuthHandlerFactory* http_auth_handler_factory_;
234 ProxyService* proxy_service_; 241 ProxyService* proxy_service_;
235 scoped_refptr<SSLConfigService> ssl_config_service_; 242 scoped_refptr<SSLConfigService> ssl_config_service_;
236 NetworkDelegate* network_delegate_; 243 NetworkDelegate* network_delegate_;
237 HttpServerProperties* http_server_properties_; 244 HttpServerProperties* http_server_properties_;
238 scoped_refptr<CookieStore> cookie_store_; 245 scoped_refptr<CookieStore> cookie_store_;
239 TransportSecurityState* transport_security_state_; 246 TransportSecurityState* transport_security_state_;
240 #if !defined(DISABLE_FTP_SUPPORT) 247 #if !defined(DISABLE_FTP_SUPPORT)
241 scoped_ptr<FtpAuthCache> ftp_auth_cache_; 248 scoped_ptr<FtpAuthCache> ftp_auth_cache_;
242 #endif 249 #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 250 // 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 251 // used in communication with a server but is used to construct a suggested
247 // filename for file download. 252 // filename for file download.
248 std::string referrer_charset_; 253 std::string referrer_charset_;
249 HttpTransactionFactory* http_transaction_factory_; 254 HttpTransactionFactory* http_transaction_factory_;
250 FtpTransactionFactory* ftp_transaction_factory_; 255 FtpTransactionFactory* ftp_transaction_factory_;
251 const URLRequestJobFactory* job_factory_; 256 const URLRequestJobFactory* job_factory_;
252 URLRequestThrottlerManager* throttler_manager_; 257 URLRequestThrottlerManager* throttler_manager_;
258 HttpUserAgentSettings* http_user_agent_settings_;
willchan no longer on Chromium 2012/10/24 03:40:10 Please move this next to HttpServerProperties. I'
253 259
254 // --------------------------------------------------------------------------- 260 // ---------------------------------------------------------------------------
255 // Important: When adding any new members below, consider whether they need to 261 // Important: When adding any new members below, consider whether they need to
256 // be added to CopyFrom. 262 // be added to CopyFrom.
257 // --------------------------------------------------------------------------- 263 // ---------------------------------------------------------------------------
258 264
259 scoped_ptr<std::set<const URLRequest*> > url_requests_; 265 scoped_ptr<std::set<const URLRequest*> > url_requests_;
260 266
261 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); 267 DISALLOW_COPY_AND_ASSIGN(URLRequestContext);
262 }; 268 };
263 269
264 } // namespace net 270 } // namespace net
265 271
266 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 272 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698