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

Side by Side Diff: net/url_request/url_request_context_builder.h

Issue 1492943002: Allow replacing the HttpAuthHandlerFactory in URLRequestContextBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Not a todo Created 5 years 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
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 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
11 // populated with "sane" default values. Read through the comments to figure out 11 // populated with "sane" default values. Read through the comments to figure out
12 // what these are. 12 // what these are.
13 13
14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
16 16
17 #include <string> 17 #include <string>
18 #include <vector>
19 18
20 #include "base/basictypes.h" 19 #include "base/basictypes.h"
21 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
22 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
23 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
24 #include "base/memory/scoped_vector.h" 23 #include "base/memory/scoped_vector.h"
25 #include "build/build_config.h" 24 #include "build/build_config.h"
26 #include "net/base/net_export.h" 25 #include "net/base/net_export.h"
27 #include "net/base/network_delegate.h" 26 #include "net/base/network_delegate.h"
28 #include "net/dns/host_resolver.h" 27 #include "net/dns/host_resolver.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 host_resolver_ = host_resolver.Pass(); 154 host_resolver_ = host_resolver.Pass();
156 } 155 }
157 156
158 // Uses BasicNetworkDelegate by default. Note that calling Build will unset 157 // Uses BasicNetworkDelegate by default. Note that calling Build will unset
159 // any custom delegate in builder, so this must be called each time before 158 // any custom delegate in builder, so this must be called each time before
160 // Build is called. 159 // Build is called.
161 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) { 160 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) {
162 network_delegate_ = delegate.Pass(); 161 network_delegate_ = delegate.Pass();
163 } 162 }
164 163
165 // Adds additional auth handler factories to be used in addition to what is 164 // Sets a specific HttpAuthHandlerFactory to be used by the URLRequestContext
166 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme| 165 // rather than the default |HttpAuthHandlerRegistryFactory|. The builder
167 // and |factory| are provided. The builder takes ownership of the factory and 166 // takes ownership of the factory and will eventually transfer it to the new
168 // Build() must be called after this method. 167 // URLRequestContext. Note that since Build will transfer ownership, the
169 void add_http_auth_handler_factory(const std::string& scheme, 168 // custom factory will be unset and this must be called before the next Build
170 HttpAuthHandlerFactory* factory) { 169 // to set another custom one.
171 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory)); 170 void SetHttpAuthHandlerFactory(scoped_ptr<HttpAuthHandlerFactory> factory);
172 }
173 171
174 // By default HttpCache is enabled with a default constructed HttpCacheParams. 172 // By default HttpCache is enabled with a default constructed HttpCacheParams.
175 void EnableHttpCache(const HttpCacheParams& params); 173 void EnableHttpCache(const HttpCacheParams& params);
176 void DisableHttpCache(); 174 void DisableHttpCache();
177 175
178 // Override default HttpNetworkSession::Params settings. 176 // Override default HttpNetworkSession::Params settings.
179 void set_http_network_session_params( 177 void set_http_network_session_params(
180 const HttpNetworkSessionParams& http_network_session_params) { 178 const HttpNetworkSessionParams& http_network_session_params) {
181 http_network_session_params_ = http_network_session_params; 179 http_network_session_params_ = http_network_session_params;
182 } 180 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } 252 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; }
255 253
256 // Sets a specific HttpServerProperties for use in the 254 // Sets a specific HttpServerProperties for use in the
257 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. 255 // URLRequestContext rather than creating a default HttpServerPropertiesImpl.
258 void SetHttpServerProperties( 256 void SetHttpServerProperties(
259 scoped_ptr<HttpServerProperties> http_server_properties); 257 scoped_ptr<HttpServerProperties> http_server_properties);
260 258
261 scoped_ptr<URLRequestContext> Build(); 259 scoped_ptr<URLRequestContext> Build();
262 260
263 private: 261 private:
264 struct NET_EXPORT SchemeFactory {
265 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory);
266 ~SchemeFactory();
267
268 std::string scheme;
269 HttpAuthHandlerFactory* factory;
270 };
271
272 std::string accept_language_; 262 std::string accept_language_;
273 std::string user_agent_; 263 std::string user_agent_;
274 // Include support for data:// requests. 264 // Include support for data:// requests.
275 bool data_enabled_; 265 bool data_enabled_;
276 #if !defined(DISABLE_FILE_SUPPORT) 266 #if !defined(DISABLE_FILE_SUPPORT)
277 // Include support for file:// requests. 267 // Include support for file:// requests.
278 bool file_enabled_; 268 bool file_enabled_;
279 #endif 269 #endif
280 #if !defined(DISABLE_FTP_SUPPORT) 270 #if !defined(DISABLE_FTP_SUPPORT)
281 // Include support for ftp:// requests. 271 // Include support for ftp:// requests.
282 bool ftp_enabled_; 272 bool ftp_enabled_;
283 #endif 273 #endif
284 bool http_cache_enabled_; 274 bool http_cache_enabled_;
285 bool throttling_enabled_; 275 bool throttling_enabled_;
286 bool backoff_enabled_; 276 bool backoff_enabled_;
287 bool sdch_enabled_; 277 bool sdch_enabled_;
288 278
289 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 279 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
290 HttpCacheParams http_cache_params_; 280 HttpCacheParams http_cache_params_;
291 HttpNetworkSessionParams http_network_session_params_; 281 HttpNetworkSessionParams http_network_session_params_;
292 base::FilePath transport_security_persister_path_; 282 base::FilePath transport_security_persister_path_;
293 NetLog* net_log_; 283 NetLog* net_log_;
294 scoped_ptr<HostResolver> host_resolver_; 284 scoped_ptr<HostResolver> host_resolver_;
295 scoped_ptr<ChannelIDService> channel_id_service_; 285 scoped_ptr<ChannelIDService> channel_id_service_;
296 scoped_ptr<ProxyConfigService> proxy_config_service_; 286 scoped_ptr<ProxyConfigService> proxy_config_service_;
297 scoped_ptr<ProxyService> proxy_service_; 287 scoped_ptr<ProxyService> proxy_service_;
298 scoped_ptr<NetworkDelegate> network_delegate_; 288 scoped_ptr<NetworkDelegate> network_delegate_;
299 scoped_refptr<CookieStore> cookie_store_; 289 scoped_refptr<CookieStore> cookie_store_;
300 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; 290 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
301 std::vector<SchemeFactory> extra_http_auth_handlers_; 291 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
302 scoped_ptr<CertVerifier> cert_verifier_; 292 scoped_ptr<CertVerifier> cert_verifier_;
303 ScopedVector<URLRequestInterceptor> url_request_interceptors_; 293 ScopedVector<URLRequestInterceptor> url_request_interceptors_;
304 scoped_ptr<HttpServerProperties> http_server_properties_; 294 scoped_ptr<HttpServerProperties> http_server_properties_;
305 295
306 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); 296 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
307 }; 297 };
308 298
309 } // namespace net 299 } // namespace net
310 300
311 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 301 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
OLDNEW
« no previous file with comments | « android_webview/browser/net/aw_url_request_context_getter.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698