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 is useful for building a simple URLRequestContext. Most creators | 5 // This class is useful for building a simple URLRequestContext. Most creators |
6 // of new URLRequestContexts should use this helper class to construct it. Call | 6 // of new URLRequestContexts should use this helper class to construct it. Call |
7 // any configuration params, and when done, invoke Build() to construct the | 7 // any configuration params, and when done, invoke Build() to construct the |
8 // URLRequestContext. This URLRequestContext will own all its own storage. | 8 // URLRequestContext. This URLRequestContext will own all its own storage. |
9 // | 9 // |
10 // URLRequestContextBuilder and its associated params classes are initially | 10 // URLRequestContextBuilder and its associated params classes are initially |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "net/base/net_export.h" | 25 #include "net/base/net_export.h" |
26 #include "net/base/network_delegate.h" | 26 #include "net/base/network_delegate.h" |
27 #include "net/dns/host_resolver.h" | 27 #include "net/dns/host_resolver.h" |
28 #include "net/proxy/proxy_config_service.h" | 28 #include "net/proxy/proxy_config_service.h" |
29 #include "net/proxy/proxy_service.h" | 29 #include "net/proxy/proxy_service.h" |
30 #include "net/quic/quic_protocol.h" | 30 #include "net/quic/quic_protocol.h" |
31 #include "net/socket/next_proto.h" | 31 #include "net/socket/next_proto.h" |
32 | 32 |
33 namespace net { | 33 namespace net { |
34 | 34 |
| 35 class ChannelIDService; |
| 36 class CookieStore; |
35 class FtpTransactionFactory; | 37 class FtpTransactionFactory; |
36 class HostMappingRules; | 38 class HostMappingRules; |
37 class HttpAuthHandlerFactory; | 39 class HttpAuthHandlerFactory; |
38 class ProxyConfigService; | 40 class ProxyConfigService; |
39 class URLRequestContext; | 41 class URLRequestContext; |
40 | 42 |
41 class NET_EXPORT URLRequestContextBuilder { | 43 class NET_EXPORT URLRequestContextBuilder { |
42 public: | 44 public: |
43 struct NET_EXPORT HttpCacheParams { | 45 struct NET_EXPORT HttpCacheParams { |
44 enum Type { | 46 enum Type { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void set_quic_connection_options( | 169 void set_quic_connection_options( |
168 const QuicTagVector& quic_connection_options) { | 170 const QuicTagVector& quic_connection_options) { |
169 http_network_session_params_.quic_connection_options = | 171 http_network_session_params_.quic_connection_options = |
170 quic_connection_options; | 172 quic_connection_options; |
171 } | 173 } |
172 | 174 |
173 void set_throttling_enabled(bool throttling_enabled) { | 175 void set_throttling_enabled(bool throttling_enabled) { |
174 throttling_enabled_ = throttling_enabled; | 176 throttling_enabled_ = throttling_enabled; |
175 } | 177 } |
176 | 178 |
177 void set_channel_id_enabled(bool enable) { | 179 // Override the default in-memory cookie store and channel id service. |
178 channel_id_enabled_ = enable; | 180 // |cookie_store| must not be NULL. |channel_id_service| may be NULL to |
179 } | 181 // disable channel id for this context. |
| 182 // Note that a persistent cookie store should not be used with an in-memory |
| 183 // channel id service, and one cookie store should not be shared between |
| 184 // multiple channel-id stores (or used both with and without a channel id |
| 185 // store). |
| 186 void SetCookieAndChannelIdStores( |
| 187 const scoped_refptr<CookieStore>& cookie_store, |
| 188 scoped_ptr<ChannelIDService> channel_id_service); |
180 | 189 |
181 URLRequestContext* Build(); | 190 URLRequestContext* Build(); |
182 | 191 |
183 private: | 192 private: |
184 struct NET_EXPORT SchemeFactory { | 193 struct NET_EXPORT SchemeFactory { |
185 SchemeFactory(const std::string& scheme, | 194 SchemeFactory(const std::string& scheme, |
186 net::HttpAuthHandlerFactory* factory); | 195 net::HttpAuthHandlerFactory* factory); |
187 ~SchemeFactory(); | 196 ~SchemeFactory(); |
188 | 197 |
189 std::string scheme; | 198 std::string scheme; |
190 net::HttpAuthHandlerFactory* factory; | 199 net::HttpAuthHandlerFactory* factory; |
191 }; | 200 }; |
192 | 201 |
193 std::string accept_language_; | 202 std::string accept_language_; |
194 std::string user_agent_; | 203 std::string user_agent_; |
195 // Include support for data:// requests. | 204 // Include support for data:// requests. |
196 bool data_enabled_; | 205 bool data_enabled_; |
197 #if !defined(DISABLE_FILE_SUPPORT) | 206 #if !defined(DISABLE_FILE_SUPPORT) |
198 // Include support for file:// requests. | 207 // Include support for file:// requests. |
199 bool file_enabled_; | 208 bool file_enabled_; |
200 #endif | 209 #endif |
201 #if !defined(DISABLE_FTP_SUPPORT) | 210 #if !defined(DISABLE_FTP_SUPPORT) |
202 // Include support for ftp:// requests. | 211 // Include support for ftp:// requests. |
203 bool ftp_enabled_; | 212 bool ftp_enabled_; |
204 #endif | 213 #endif |
205 bool http_cache_enabled_; | 214 bool http_cache_enabled_; |
206 bool throttling_enabled_; | 215 bool throttling_enabled_; |
207 bool channel_id_enabled_; | |
208 | 216 |
209 HttpCacheParams http_cache_params_; | 217 HttpCacheParams http_cache_params_; |
210 HttpNetworkSessionParams http_network_session_params_; | 218 HttpNetworkSessionParams http_network_session_params_; |
211 base::FilePath transport_security_persister_path_; | 219 base::FilePath transport_security_persister_path_; |
212 scoped_ptr<NetLog> net_log_; | 220 scoped_ptr<NetLog> net_log_; |
213 scoped_ptr<HostResolver> host_resolver_; | 221 scoped_ptr<HostResolver> host_resolver_; |
| 222 scoped_ptr<ChannelIDService> channel_id_service_; |
214 scoped_ptr<ProxyConfigService> proxy_config_service_; | 223 scoped_ptr<ProxyConfigService> proxy_config_service_; |
215 scoped_ptr<ProxyService> proxy_service_; | 224 scoped_ptr<ProxyService> proxy_service_; |
216 scoped_ptr<NetworkDelegate> network_delegate_; | 225 scoped_ptr<NetworkDelegate> network_delegate_; |
| 226 scoped_refptr<CookieStore> cookie_store_; |
217 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; | 227 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; |
218 std::vector<SchemeFactory> extra_http_auth_handlers_; | 228 std::vector<SchemeFactory> extra_http_auth_handlers_; |
219 | 229 |
220 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 230 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
221 }; | 231 }; |
222 | 232 |
223 } // namespace net | 233 } // namespace net |
224 | 234 |
225 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 235 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
OLD | NEW |