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