| 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 |
| 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 <stdint.h> | 17 #include <stdint.h> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <unordered_map> | 19 #include <unordered_map> |
| 20 #include <utility> | 20 #include <utility> |
| 21 | 21 |
| 22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
| 23 #include "base/macros.h" | 23 #include "base/macros.h" |
| 24 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 25 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "net/base/net_export.h" | 27 #include "net/base/net_export.h" |
| 28 #include "net/base/network_delegate.h" | 28 #include "net/base/network_delegate.h" |
| 29 #include "net/base/proxy_delegate.h" |
| 29 #include "net/dns/host_resolver.h" | 30 #include "net/dns/host_resolver.h" |
| 30 #include "net/http/http_network_session.h" | 31 #include "net/http/http_network_session.h" |
| 31 #include "net/proxy/proxy_config_service.h" | 32 #include "net/proxy/proxy_config_service.h" |
| 32 #include "net/proxy/proxy_service.h" | 33 #include "net/proxy/proxy_service.h" |
| 33 #include "net/quic/quic_protocol.h" | 34 #include "net/quic/quic_protocol.h" |
| 34 #include "net/socket/next_proto.h" | 35 #include "net/socket/next_proto.h" |
| 35 | 36 |
| 36 namespace base { | 37 namespace base { |
| 37 class SingleThreadTaskRunner; | 38 class SingleThreadTaskRunner; |
| 38 } | 39 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 host_resolver_ = std::move(host_resolver); | 165 host_resolver_ = std::move(host_resolver); |
| 165 } | 166 } |
| 166 | 167 |
| 167 // Uses BasicNetworkDelegate by default. Note that calling Build will unset | 168 // Uses BasicNetworkDelegate by default. Note that calling Build will unset |
| 168 // any custom delegate in builder, so this must be called each time before | 169 // any custom delegate in builder, so this must be called each time before |
| 169 // Build is called. | 170 // Build is called. |
| 170 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) { | 171 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) { |
| 171 network_delegate_ = std::move(delegate); | 172 network_delegate_ = std::move(delegate); |
| 172 } | 173 } |
| 173 | 174 |
| 175 // Temporarily stores a ProxyDelegate. Ownership is transferred to |
| 176 // UrlRequestContextStorage during Build. |
| 177 void set_proxy_delegate(scoped_ptr<ProxyDelegate> delegate) { |
| 178 proxy_delegate_ = std::move(delegate); |
| 179 } |
| 180 |
| 174 // Sets a specific HttpAuthHandlerFactory to be used by the URLRequestContext | 181 // Sets a specific HttpAuthHandlerFactory to be used by the URLRequestContext |
| 175 // rather than the default |HttpAuthHandlerRegistryFactory|. The builder | 182 // rather than the default |HttpAuthHandlerRegistryFactory|. The builder |
| 176 // takes ownership of the factory and will eventually transfer it to the new | 183 // takes ownership of the factory and will eventually transfer it to the new |
| 177 // URLRequestContext. Note that since Build will transfer ownership, the | 184 // URLRequestContext. Note that since Build will transfer ownership, the |
| 178 // custom factory will be unset and this must be called before the next Build | 185 // custom factory will be unset and this must be called before the next Build |
| 179 // to set another custom one. | 186 // to set another custom one. |
| 180 void SetHttpAuthHandlerFactory(scoped_ptr<HttpAuthHandlerFactory> factory); | 187 void SetHttpAuthHandlerFactory(scoped_ptr<HttpAuthHandlerFactory> factory); |
| 181 | 188 |
| 182 // By default HttpCache is enabled with a default constructed HttpCacheParams. | 189 // By default HttpCache is enabled with a default constructed HttpCacheParams. |
| 183 void EnableHttpCache(const HttpCacheParams& params); | 190 void EnableHttpCache(const HttpCacheParams& params); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 331 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 325 HttpCacheParams http_cache_params_; | 332 HttpCacheParams http_cache_params_; |
| 326 HttpNetworkSessionParams http_network_session_params_; | 333 HttpNetworkSessionParams http_network_session_params_; |
| 327 base::FilePath transport_security_persister_path_; | 334 base::FilePath transport_security_persister_path_; |
| 328 NetLog* net_log_; | 335 NetLog* net_log_; |
| 329 scoped_ptr<HostResolver> host_resolver_; | 336 scoped_ptr<HostResolver> host_resolver_; |
| 330 scoped_ptr<ChannelIDService> channel_id_service_; | 337 scoped_ptr<ChannelIDService> channel_id_service_; |
| 331 scoped_ptr<ProxyConfigService> proxy_config_service_; | 338 scoped_ptr<ProxyConfigService> proxy_config_service_; |
| 332 scoped_ptr<ProxyService> proxy_service_; | 339 scoped_ptr<ProxyService> proxy_service_; |
| 333 scoped_ptr<NetworkDelegate> network_delegate_; | 340 scoped_ptr<NetworkDelegate> network_delegate_; |
| 341 scoped_ptr<ProxyDelegate> proxy_delegate_; |
| 334 scoped_refptr<CookieStore> cookie_store_; | 342 scoped_refptr<CookieStore> cookie_store_; |
| 335 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; | 343 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; |
| 336 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; | 344 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
| 337 scoped_ptr<CertVerifier> cert_verifier_; | 345 scoped_ptr<CertVerifier> cert_verifier_; |
| 338 std::vector<scoped_ptr<URLRequestInterceptor>> url_request_interceptors_; | 346 std::vector<scoped_ptr<URLRequestInterceptor>> url_request_interceptors_; |
| 339 scoped_ptr<HttpServerProperties> http_server_properties_; | 347 scoped_ptr<HttpServerProperties> http_server_properties_; |
| 340 | 348 |
| 341 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 349 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 342 }; | 350 }; |
| 343 | 351 |
| 344 } // namespace net | 352 } // namespace net |
| 345 | 353 |
| 346 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 354 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |