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_ |
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 #include <string> |
15 | 15 |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
22 #include "net/ftp/ftp_auth_cache.h" | |
23 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
24 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
25 #include "net/http/transport_security_state.h" | 24 #include "net/http/transport_security_state.h" |
26 #include "net/ssl/ssl_config_service.h" | 25 #include "net/ssl/ssl_config_service.h" |
27 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
28 | 27 |
29 namespace net { | 28 namespace net { |
30 class CertVerifier; | 29 class CertVerifier; |
31 class CookieStore; | 30 class CookieStore; |
32 class FraudulentCertificateReporter; | 31 class FraudulentCertificateReporter; |
33 class FtpTransactionFactory; | |
34 class HostResolver; | 32 class HostResolver; |
35 class HttpAuthHandlerFactory; | 33 class HttpAuthHandlerFactory; |
36 class HttpTransactionFactory; | 34 class HttpTransactionFactory; |
37 class HttpUserAgentSettings; | 35 class HttpUserAgentSettings; |
38 class NetworkDelegate; | 36 class NetworkDelegate; |
39 class ServerBoundCertService; | 37 class ServerBoundCertService; |
40 class ProxyService; | 38 class ProxyService; |
41 class URLRequest; | 39 class URLRequest; |
42 class URLRequestJobFactory; | 40 class URLRequestJobFactory; |
43 class URLRequestThrottlerManager; | 41 class URLRequestThrottlerManager; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 122 } |
125 | 123 |
126 // Gets the http transaction factory for this context. | 124 // Gets the http transaction factory for this context. |
127 HttpTransactionFactory* http_transaction_factory() const { | 125 HttpTransactionFactory* http_transaction_factory() const { |
128 return http_transaction_factory_; | 126 return http_transaction_factory_; |
129 } | 127 } |
130 void set_http_transaction_factory(HttpTransactionFactory* factory) { | 128 void set_http_transaction_factory(HttpTransactionFactory* factory) { |
131 http_transaction_factory_ = factory; | 129 http_transaction_factory_ = factory; |
132 } | 130 } |
133 | 131 |
134 // Gets the ftp transaction factory for this context. | |
135 FtpTransactionFactory* ftp_transaction_factory() const { | |
136 return ftp_transaction_factory_; | |
137 } | |
138 void set_ftp_transaction_factory(FtpTransactionFactory* factory) { | |
139 ftp_transaction_factory_ = factory; | |
140 } | |
141 | |
142 void set_network_delegate(NetworkDelegate* network_delegate) { | 132 void set_network_delegate(NetworkDelegate* network_delegate) { |
143 network_delegate_ = network_delegate; | 133 network_delegate_ = network_delegate; |
144 } | 134 } |
145 NetworkDelegate* network_delegate() const { return network_delegate_; } | 135 NetworkDelegate* network_delegate() const { return network_delegate_; } |
146 | 136 |
147 void set_http_server_properties( | 137 void set_http_server_properties( |
148 HttpServerProperties* http_server_properties) { | 138 HttpServerProperties* http_server_properties) { |
149 http_server_properties_ = http_server_properties; | 139 http_server_properties_ = http_server_properties; |
150 } | 140 } |
151 HttpServerProperties* http_server_properties() const { | 141 HttpServerProperties* http_server_properties() const { |
152 return http_server_properties_; | 142 return http_server_properties_; |
153 } | 143 } |
154 | 144 |
155 // Gets the cookie store for this context (may be null, in which case | 145 // Gets the cookie store for this context (may be null, in which case |
156 // cookies are not stored). | 146 // cookies are not stored). |
157 CookieStore* cookie_store() const { return cookie_store_.get(); } | 147 CookieStore* cookie_store() const { return cookie_store_.get(); } |
158 void set_cookie_store(CookieStore* cookie_store); | 148 void set_cookie_store(CookieStore* cookie_store); |
159 | 149 |
160 TransportSecurityState* transport_security_state() const { | 150 TransportSecurityState* transport_security_state() const { |
161 return transport_security_state_; | 151 return transport_security_state_; |
162 } | 152 } |
163 void set_transport_security_state( | 153 void set_transport_security_state( |
164 TransportSecurityState* state) { | 154 TransportSecurityState* state) { |
165 transport_security_state_ = state; | 155 transport_security_state_ = state; |
166 } | 156 } |
167 | 157 |
168 // Gets the FTP authentication cache for this context. | |
169 FtpAuthCache* ftp_auth_cache() const { | |
170 #if !defined(DISABLE_FTP_SUPPORT) | |
171 return ftp_auth_cache_.get(); | |
172 #else | |
173 return NULL; | |
174 #endif | |
175 } | |
176 | |
177 // --------------------------------------------------------------------------- | 158 // --------------------------------------------------------------------------- |
178 // Legacy accessors that delegate to http_user_agent_settings_. | 159 // Legacy accessors that delegate to http_user_agent_settings_. |
179 // TODO(pauljensen): Remove after all clients are updated to directly access | 160 // TODO(pauljensen): Remove after all clients are updated to directly access |
180 // http_user_agent_settings_. | 161 // http_user_agent_settings_. |
181 // Gets the value of 'Accept-Language' header field. | 162 // Gets the value of 'Accept-Language' header field. |
182 std::string GetAcceptLanguage() const; | 163 std::string GetAcceptLanguage() const; |
183 // Gets the UA string to use for the given URL. Pass an invalid URL (such as | 164 // Gets the UA string to use for the given URL. Pass an invalid URL (such as |
184 // GURL()) to get the default UA string. | 165 // GURL()) to get the default UA string. |
185 std::string GetUserAgent(const GURL& url) const; | 166 std::string GetUserAgent(const GURL& url) const; |
186 // --------------------------------------------------------------------------- | 167 // --------------------------------------------------------------------------- |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 ServerBoundCertService* server_bound_cert_service_; | 211 ServerBoundCertService* server_bound_cert_service_; |
231 FraudulentCertificateReporter* fraudulent_certificate_reporter_; | 212 FraudulentCertificateReporter* fraudulent_certificate_reporter_; |
232 HttpAuthHandlerFactory* http_auth_handler_factory_; | 213 HttpAuthHandlerFactory* http_auth_handler_factory_; |
233 ProxyService* proxy_service_; | 214 ProxyService* proxy_service_; |
234 scoped_refptr<SSLConfigService> ssl_config_service_; | 215 scoped_refptr<SSLConfigService> ssl_config_service_; |
235 NetworkDelegate* network_delegate_; | 216 NetworkDelegate* network_delegate_; |
236 HttpServerProperties* http_server_properties_; | 217 HttpServerProperties* http_server_properties_; |
237 HttpUserAgentSettings* http_user_agent_settings_; | 218 HttpUserAgentSettings* http_user_agent_settings_; |
238 scoped_refptr<CookieStore> cookie_store_; | 219 scoped_refptr<CookieStore> cookie_store_; |
239 TransportSecurityState* transport_security_state_; | 220 TransportSecurityState* transport_security_state_; |
240 #if !defined(DISABLE_FTP_SUPPORT) | |
241 scoped_ptr<FtpAuthCache> ftp_auth_cache_; | |
242 #endif | |
243 HttpTransactionFactory* http_transaction_factory_; | 221 HttpTransactionFactory* http_transaction_factory_; |
244 FtpTransactionFactory* ftp_transaction_factory_; | |
245 const URLRequestJobFactory* job_factory_; | 222 const URLRequestJobFactory* job_factory_; |
246 URLRequestThrottlerManager* throttler_manager_; | 223 URLRequestThrottlerManager* throttler_manager_; |
247 | 224 |
248 // --------------------------------------------------------------------------- | 225 // --------------------------------------------------------------------------- |
249 // 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 |
250 // be added to CopyFrom. | 227 // be added to CopyFrom. |
251 // --------------------------------------------------------------------------- | 228 // --------------------------------------------------------------------------- |
252 | 229 |
253 scoped_ptr<std::set<const URLRequest*> > url_requests_; | 230 scoped_ptr<std::set<const URLRequest*> > url_requests_; |
254 | 231 |
255 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 232 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
256 }; | 233 }; |
257 | 234 |
258 } // namespace net | 235 } // namespace net |
259 | 236 |
260 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 237 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
OLD | NEW |