OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ |
(...skipping 14 matching lines...) Expand all Loading... |
26 class CookieStore; | 26 class CookieStore; |
27 class DnsCertProvenanceChecker; | 27 class DnsCertProvenanceChecker; |
28 class DnsRRResolver; | 28 class DnsRRResolver; |
29 class FtpTransactionFactory; | 29 class FtpTransactionFactory; |
30 class HostResolver; | 30 class HostResolver; |
31 class HttpAuthHandlerFactory; | 31 class HttpAuthHandlerFactory; |
32 class HttpNetworkDelegate; | 32 class HttpNetworkDelegate; |
33 class HttpTransactionFactory; | 33 class HttpTransactionFactory; |
34 class SSLConfigService; | 34 class SSLConfigService; |
35 class URLRequest; | 35 class URLRequest; |
36 } // namespace net | |
37 | 36 |
38 // Subclass to provide application-specific context for net::URLRequest | 37 // Subclass to provide application-specific context for URLRequest |
39 // instances. | 38 // instances. |
40 class URLRequestContext | 39 class URLRequestContext |
41 : public base::RefCountedThreadSafe<URLRequestContext>, | 40 : public base::RefCountedThreadSafe<URLRequestContext>, |
42 public base::NonThreadSafe { | 41 public base::NonThreadSafe { |
43 public: | 42 public: |
44 URLRequestContext(); | 43 URLRequestContext(); |
45 | 44 |
46 net::NetLog* net_log() const { | 45 NetLog* net_log() const { |
47 return net_log_; | 46 return net_log_; |
48 } | 47 } |
49 | 48 |
50 void set_net_log(net::NetLog* net_log) { | 49 void set_net_log(NetLog* net_log) { |
51 net_log_ = net_log; | 50 net_log_ = net_log; |
52 } | 51 } |
53 | 52 |
54 net::HostResolver* host_resolver() const { | 53 HostResolver* host_resolver() const { |
55 return host_resolver_; | 54 return host_resolver_; |
56 } | 55 } |
57 | 56 |
58 void set_host_resolver(net::HostResolver* host_resolver) { | 57 void set_host_resolver(HostResolver* host_resolver) { |
59 host_resolver_ = host_resolver; | 58 host_resolver_ = host_resolver; |
60 } | 59 } |
61 | 60 |
62 net::CertVerifier* cert_verifier() const { | 61 CertVerifier* cert_verifier() const { |
63 return cert_verifier_; | 62 return cert_verifier_; |
64 } | 63 } |
65 | 64 |
66 void set_cert_verifier(net::CertVerifier* cert_verifier) { | 65 void set_cert_verifier(CertVerifier* cert_verifier) { |
67 cert_verifier_ = cert_verifier; | 66 cert_verifier_ = cert_verifier; |
68 } | 67 } |
69 | 68 |
70 net::DnsRRResolver* dnsrr_resolver() const { | 69 DnsRRResolver* dnsrr_resolver() const { |
71 return dnsrr_resolver_; | 70 return dnsrr_resolver_; |
72 } | 71 } |
73 | 72 |
74 void set_dnsrr_resolver(net::DnsRRResolver* dnsrr_resolver) { | 73 void set_dnsrr_resolver(DnsRRResolver* dnsrr_resolver) { |
75 dnsrr_resolver_ = dnsrr_resolver; | 74 dnsrr_resolver_ = dnsrr_resolver; |
76 } | 75 } |
77 | 76 |
78 net::DnsCertProvenanceChecker* dns_cert_checker() const { | 77 DnsCertProvenanceChecker* dns_cert_checker() const { |
79 return dns_cert_checker_.get(); | 78 return dns_cert_checker_.get(); |
80 } | 79 } |
81 | 80 |
82 // Get the proxy service for this context. | 81 // Get the proxy service for this context. |
83 net::ProxyService* proxy_service() const { | 82 ProxyService* proxy_service() const { |
84 return proxy_service_; | 83 return proxy_service_; |
85 } | 84 } |
86 | 85 |
87 void set_proxy_service(net::ProxyService* proxy_service) { | 86 void set_proxy_service(ProxyService* proxy_service) { |
88 proxy_service_ = proxy_service; | 87 proxy_service_ = proxy_service; |
89 } | 88 } |
90 | 89 |
91 // Get the ssl config service for this context. | 90 // Get the ssl config service for this context. |
92 net::SSLConfigService* ssl_config_service() const { | 91 SSLConfigService* ssl_config_service() const { |
93 return ssl_config_service_; | 92 return ssl_config_service_; |
94 } | 93 } |
95 | 94 |
96 // Gets the HTTP Authentication Handler Factory for this context. | 95 // Gets the HTTP Authentication Handler Factory for this context. |
97 // The factory is only valid for the lifetime of this URLRequestContext | 96 // The factory is only valid for the lifetime of this URLRequestContext |
98 net::HttpAuthHandlerFactory* http_auth_handler_factory() { | 97 HttpAuthHandlerFactory* http_auth_handler_factory() { |
99 return http_auth_handler_factory_; | 98 return http_auth_handler_factory_; |
100 } | 99 } |
101 void set_http_auth_handler_factory(net::HttpAuthHandlerFactory* factory) { | 100 void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { |
102 http_auth_handler_factory_ = factory; | 101 http_auth_handler_factory_ = factory; |
103 } | 102 } |
104 | 103 |
105 // Gets the http transaction factory for this context. | 104 // Gets the http transaction factory for this context. |
106 net::HttpTransactionFactory* http_transaction_factory() const { | 105 HttpTransactionFactory* http_transaction_factory() const { |
107 return http_transaction_factory_; | 106 return http_transaction_factory_; |
108 } | 107 } |
109 | 108 |
110 void set_http_transaction_factory(net::HttpTransactionFactory* factory) { | 109 void set_http_transaction_factory(HttpTransactionFactory* factory) { |
111 http_transaction_factory_ = factory; | 110 http_transaction_factory_ = factory; |
112 } | 111 } |
113 | 112 |
114 // Gets the ftp transaction factory for this context. | 113 // Gets the ftp transaction factory for this context. |
115 net::FtpTransactionFactory* ftp_transaction_factory() { | 114 FtpTransactionFactory* ftp_transaction_factory() { |
116 return ftp_transaction_factory_; | 115 return ftp_transaction_factory_; |
117 } | 116 } |
118 | 117 |
119 // Gets the cookie store for this context (may be null, in which case | 118 // Gets the cookie store for this context (may be null, in which case |
120 // cookies are not stored). | 119 // cookies are not stored). |
121 net::CookieStore* cookie_store() { return cookie_store_.get(); } | 120 CookieStore* cookie_store() { return cookie_store_.get(); } |
122 | 121 |
123 void set_cookie_store(net::CookieStore* cookie_store); | 122 void set_cookie_store(CookieStore* cookie_store); |
124 | 123 |
125 // Gets the cookie policy for this context (may be null, in which case | 124 // Gets the cookie policy for this context (may be null, in which case |
126 // cookies are allowed). | 125 // cookies are allowed). |
127 net::CookiePolicy* cookie_policy() { return cookie_policy_; } | 126 CookiePolicy* cookie_policy() { return cookie_policy_; } |
128 | 127 |
129 net::TransportSecurityState* transport_security_state() { | 128 TransportSecurityState* transport_security_state() { |
130 return transport_security_state_; } | 129 return transport_security_state_; } |
131 | 130 |
132 // Gets the FTP authentication cache for this context. | 131 // Gets the FTP authentication cache for this context. |
133 net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } | 132 FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } |
134 | 133 |
135 // Gets the value of 'Accept-Charset' header field. | 134 // Gets the value of 'Accept-Charset' header field. |
136 const std::string& accept_charset() const { return accept_charset_; } | 135 const std::string& accept_charset() const { return accept_charset_; } |
137 | 136 |
138 // Gets the value of 'Accept-Language' header field. | 137 // Gets the value of 'Accept-Language' header field. |
139 const std::string& accept_language() const { return accept_language_; } | 138 const std::string& accept_language() const { return accept_language_; } |
140 | 139 |
141 // Gets the UA string to use for the given URL. Pass an invalid URL (such as | 140 // Gets the UA string to use for the given URL. Pass an invalid URL (such as |
142 // GURL()) to get the default UA string. Subclasses should override this | 141 // GURL()) to get the default UA string. Subclasses should override this |
143 // method to provide a UA string. | 142 // method to provide a UA string. |
(...skipping 11 matching lines...) Expand all Loading... |
155 bool is_main() const { return is_main_; } | 154 bool is_main() const { return is_main_; } |
156 void set_is_main(bool is_main) { is_main_ = is_main; } | 155 void set_is_main(bool is_main) { is_main_ = is_main; } |
157 | 156 |
158 protected: | 157 protected: |
159 friend class base::RefCountedThreadSafe<URLRequestContext>; | 158 friend class base::RefCountedThreadSafe<URLRequestContext>; |
160 | 159 |
161 virtual ~URLRequestContext(); | 160 virtual ~URLRequestContext(); |
162 | 161 |
163 // The following members are expected to be initialized and owned by | 162 // The following members are expected to be initialized and owned by |
164 // subclasses. | 163 // subclasses. |
165 net::NetLog* net_log_; | 164 NetLog* net_log_; |
166 net::HostResolver* host_resolver_; | 165 HostResolver* host_resolver_; |
167 net::CertVerifier* cert_verifier_; | 166 CertVerifier* cert_verifier_; |
168 net::DnsRRResolver* dnsrr_resolver_; | 167 DnsRRResolver* dnsrr_resolver_; |
169 scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; | 168 scoped_ptr<DnsCertProvenanceChecker> dns_cert_checker_; |
170 scoped_refptr<net::ProxyService> proxy_service_; | 169 scoped_refptr<ProxyService> proxy_service_; |
171 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 170 scoped_refptr<SSLConfigService> ssl_config_service_; |
172 net::HttpTransactionFactory* http_transaction_factory_; | 171 HttpTransactionFactory* http_transaction_factory_; |
173 net::FtpTransactionFactory* ftp_transaction_factory_; | 172 FtpTransactionFactory* ftp_transaction_factory_; |
174 net::HttpAuthHandlerFactory* http_auth_handler_factory_; | 173 HttpAuthHandlerFactory* http_auth_handler_factory_; |
175 net::HttpNetworkDelegate* network_delegate_; | 174 HttpNetworkDelegate* network_delegate_; |
176 scoped_refptr<net::CookieStore> cookie_store_; | 175 scoped_refptr<CookieStore> cookie_store_; |
177 net::CookiePolicy* cookie_policy_; | 176 CookiePolicy* cookie_policy_; |
178 scoped_refptr<net::TransportSecurityState> transport_security_state_; | 177 scoped_refptr<TransportSecurityState> transport_security_state_; |
179 net::FtpAuthCache ftp_auth_cache_; | 178 FtpAuthCache ftp_auth_cache_; |
180 std::string accept_language_; | 179 std::string accept_language_; |
181 std::string accept_charset_; | 180 std::string accept_charset_; |
182 // The charset of the referrer where this request comes from. It's not | 181 // The charset of the referrer where this request comes from. It's not |
183 // used in communication with a server but is used to construct a suggested | 182 // used in communication with a server but is used to construct a suggested |
184 // filename for file download. | 183 // filename for file download. |
185 std::string referrer_charset_; | 184 std::string referrer_charset_; |
186 | 185 |
187 private: | 186 private: |
188 // Indicates whether or not this is the main URLRequestContext. | 187 // Indicates whether or not this is the main URLRequestContext. |
189 bool is_main_; | 188 bool is_main_; |
190 | 189 |
191 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 190 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
192 }; | 191 }; |
193 | 192 |
| 193 } // namespace net |
| 194 |
| 195 // TODO(tfarina): Fix the callers and remove this! |
| 196 typedef net::URLRequestContext URLRequestContext; |
| 197 |
194 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 198 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
OLD | NEW |