Chromium Code Reviews| 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 | 18 |
| 19 #include <map> | 19 #include <map> |
| 20 #include <memory> | 20 #include <memory> |
| 21 #include <string> | 21 #include <string> |
| 22 #include <unordered_map> | 22 #include <unordered_map> |
| 23 #include <utility> | 23 #include <utility> |
| 24 #include <vector> | 24 #include <vector> |
| 25 | 25 |
| 26 #include "base/files/file_path.h" | 26 #include "base/files/file_path.h" |
| 27 #include "base/macros.h" | 27 #include "base/macros.h" |
| 28 #include "base/memory/ref_counted.h" | 28 #include "base/memory/ref_counted.h" |
| 29 #include "base/task_scheduler/task_traits.h" | |
| 29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 30 #include "net/base/net_export.h" | 31 #include "net/base/net_export.h" |
| 31 #include "net/base/network_delegate.h" | 32 #include "net/base/network_delegate.h" |
| 32 #include "net/base/proxy_delegate.h" | 33 #include "net/base/proxy_delegate.h" |
| 33 #include "net/dns/host_resolver.h" | 34 #include "net/dns/host_resolver.h" |
| 34 #include "net/http/http_network_session.h" | 35 #include "net/http/http_network_session.h" |
| 35 #include "net/net_features.h" | 36 #include "net/net_features.h" |
| 36 #include "net/proxy/proxy_config_service.h" | 37 #include "net/proxy/proxy_config_service.h" |
| 37 #include "net/proxy/proxy_service.h" | 38 #include "net/proxy/proxy_service.h" |
| 38 #include "net/quic/core/quic_packets.h" | 39 #include "net/quic/core/quic_packets.h" |
| 39 #include "net/socket/next_proto.h" | 40 #include "net/socket/next_proto.h" |
| 40 #include "net/ssl/ssl_config_service.h" | 41 #include "net/ssl/ssl_config_service.h" |
| 41 #include "net/url_request/url_request_job_factory.h" | 42 #include "net/url_request/url_request_job_factory.h" |
| 42 | 43 |
| 43 namespace base { | 44 namespace base { |
| 44 class SingleThreadTaskRunner; | 45 class SingleThreadTaskRunner; |
| 46 class SequencedTaskRunner; | |
| 47 class TaskRunner; | |
| 45 } | 48 } |
| 46 | 49 |
| 47 namespace net { | 50 namespace net { |
| 48 | 51 |
| 49 class CertVerifier; | 52 class CertVerifier; |
| 50 class ChannelIDService; | 53 class ChannelIDService; |
| 51 class CookieStore; | 54 class CookieStore; |
| 52 class CTVerifier; | 55 class CTVerifier; |
| 53 class HttpAuthHandlerFactory; | 56 class HttpAuthHandlerFactory; |
| 54 class HttpServerProperties; | 57 class HttpServerProperties; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 // If |cookie_store| is not NULL and |channel_id_service| is NULL, | 321 // If |cookie_store| is not NULL and |channel_id_service| is NULL, |
| 319 // only ChannelIdService is disabled for this context. | 322 // only ChannelIdService is disabled for this context. |
| 320 // Note that a persistent cookie store should not be used with an in-memory | 323 // Note that a persistent cookie store should not be used with an in-memory |
| 321 // channel id service, and one cookie store should not be shared between | 324 // channel id service, and one cookie store should not be shared between |
| 322 // multiple channel-id stores (or used both with and without a channel id | 325 // multiple channel-id stores (or used both with and without a channel id |
| 323 // store). | 326 // store). |
| 324 void SetCookieAndChannelIdStores( | 327 void SetCookieAndChannelIdStores( |
| 325 std::unique_ptr<CookieStore> cookie_store, | 328 std::unique_ptr<CookieStore> cookie_store, |
| 326 std::unique_ptr<ChannelIDService> channel_id_service); | 329 std::unique_ptr<ChannelIDService> channel_id_service); |
| 327 | 330 |
| 328 // Sets the task runner used to perform file operations. If not set, one will | 331 // Sets the task runner used to perform file operations. If not set, |
| 329 // be created. | 332 // TaskSchedulers will be used instead. |
| 330 void SetFileTaskRunner( | 333 void SetFileTaskRunner( |
| 331 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 334 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 332 | 335 |
| 333 // Note that if SDCH is enabled without a policy object observing | 336 // Note that if SDCH is enabled without a policy object observing |
| 334 // the SDCH manager and handling at least Get-Dictionary events, the | 337 // the SDCH manager and handling at least Get-Dictionary events, the |
| 335 // result will be "Content-Encoding: sdch" advertisements, but no | 338 // result will be "Content-Encoding: sdch" advertisements, but no |
| 336 // dictionaries fetches and no specific dictionaries advertised. | 339 // dictionaries fetches and no specific dictionaries advertised. |
| 337 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 340 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
| 338 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 341 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
| 339 | 342 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 351 // Lets subclasses override ProxyService creation, using a ProxyService that | 354 // Lets subclasses override ProxyService creation, using a ProxyService that |
| 352 // uses the URLRequestContext itself to get PAC scripts. When this method is | 355 // uses the URLRequestContext itself to get PAC scripts. When this method is |
| 353 // invoked, the URLRequestContext is not yet ready to service requests. | 356 // invoked, the URLRequestContext is not yet ready to service requests. |
| 354 virtual std::unique_ptr<ProxyService> CreateProxyService( | 357 virtual std::unique_ptr<ProxyService> CreateProxyService( |
| 355 std::unique_ptr<ProxyConfigService> proxy_config_service, | 358 std::unique_ptr<ProxyConfigService> proxy_config_service, |
| 356 URLRequestContext* url_request_context, | 359 URLRequestContext* url_request_context, |
| 357 HostResolver* host_resolver, | 360 HostResolver* host_resolver, |
| 358 NetworkDelegate* network_delegate, | 361 NetworkDelegate* network_delegate, |
| 359 NetLog* net_log); | 362 NetLog* net_log); |
| 360 | 363 |
| 364 // Returns a TaskRunner with the specified traits. If |file_task_runner_| is | |
| 365 // non-NULL, uses that. Otherwise, uses base/task_scheduler/ and the specified | |
| 366 // traits. | |
|
Randy Smith (Not in Mondays)
2017/06/21 12:56:26
I also find myself wondering if names that capture
Randy Smith (Not in Mondays)
2017/06/21 12:56:26
nit, suggestion: It bothers me a little that we're
mmenke
2017/06/21 15:13:56
I'm open to other ideas. Largely I just wanted re
mmenke
2017/06/21 15:13:56
Done. I didn't do this in the first place mostly
| |
| 367 scoped_refptr<base::TaskRunner> GetTaskRunner(const base::TaskTraits& traits); | |
| 368 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( | |
| 369 const base::TaskTraits& traits); | |
| 370 scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner( | |
| 371 const base::TaskTraits& traits); | |
| 372 | |
| 361 private: | 373 private: |
| 362 const char* name_; | 374 const char* name_; |
| 363 bool enable_brotli_; | 375 bool enable_brotli_; |
| 364 NetworkQualityEstimator* network_quality_estimator_; | 376 NetworkQualityEstimator* network_quality_estimator_; |
| 365 | 377 |
| 366 std::string accept_language_; | 378 std::string accept_language_; |
| 367 std::string user_agent_; | 379 std::string user_agent_; |
| 368 // Include support for data:// requests. | 380 // Include support for data:// requests. |
| 369 bool data_enabled_; | 381 bool data_enabled_; |
| 370 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 382 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
| 371 // Include support for file:// requests. | 383 // Include support for file:// requests. |
| 372 bool file_enabled_; | 384 bool file_enabled_; |
| 373 #endif | 385 #endif |
| 374 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) | 386 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) |
| 375 // Include support for ftp:// requests. | 387 // Include support for ftp:// requests. |
| 376 bool ftp_enabled_; | 388 bool ftp_enabled_; |
| 377 #endif | 389 #endif |
| 378 bool http_cache_enabled_; | 390 bool http_cache_enabled_; |
| 379 bool throttling_enabled_; | 391 bool throttling_enabled_; |
| 380 bool sdch_enabled_; | 392 bool sdch_enabled_; |
| 381 bool cookie_store_set_by_client_; | 393 bool cookie_store_set_by_client_; |
| 382 | 394 |
| 383 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 395 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 396 | |
| 384 HttpCacheParams http_cache_params_; | 397 HttpCacheParams http_cache_params_; |
| 385 HttpNetworkSession::Params http_network_session_params_; | 398 HttpNetworkSession::Params http_network_session_params_; |
| 386 base::FilePath transport_security_persister_path_; | 399 base::FilePath transport_security_persister_path_; |
| 387 NetLog* net_log_; | 400 NetLog* net_log_; |
| 388 std::unique_ptr<HostResolver> host_resolver_; | 401 std::unique_ptr<HostResolver> host_resolver_; |
| 389 std::unique_ptr<ChannelIDService> channel_id_service_; | 402 std::unique_ptr<ChannelIDService> channel_id_service_; |
| 390 std::unique_ptr<ProxyConfigService> proxy_config_service_; | 403 std::unique_ptr<ProxyConfigService> proxy_config_service_; |
| 391 bool pac_quick_check_enabled_; | 404 bool pac_quick_check_enabled_; |
| 392 ProxyService::SanitizeUrlPolicy pac_sanitize_url_policy_; | 405 ProxyService::SanitizeUrlPolicy pac_sanitize_url_policy_; |
| 393 std::unique_ptr<ProxyService> proxy_service_; | 406 std::unique_ptr<ProxyService> proxy_service_; |
| 394 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 407 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 395 std::unique_ptr<NetworkDelegate> network_delegate_; | 408 std::unique_ptr<NetworkDelegate> network_delegate_; |
| 396 std::unique_ptr<ProxyDelegate> proxy_delegate_; | 409 std::unique_ptr<ProxyDelegate> proxy_delegate_; |
| 397 std::unique_ptr<CookieStore> cookie_store_; | 410 std::unique_ptr<CookieStore> cookie_store_; |
| 398 std::unique_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; | 411 std::unique_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
| 399 std::unique_ptr<CertVerifier> cert_verifier_; | 412 std::unique_ptr<CertVerifier> cert_verifier_; |
| 400 std::unique_ptr<CTVerifier> ct_verifier_; | 413 std::unique_ptr<CTVerifier> ct_verifier_; |
| 401 std::unique_ptr<net::ReportingPolicy> reporting_policy_; | 414 std::unique_ptr<net::ReportingPolicy> reporting_policy_; |
| 402 std::vector<std::unique_ptr<URLRequestInterceptor>> url_request_interceptors_; | 415 std::vector<std::unique_ptr<URLRequestInterceptor>> url_request_interceptors_; |
| 403 std::unique_ptr<HttpServerProperties> http_server_properties_; | 416 std::unique_ptr<HttpServerProperties> http_server_properties_; |
| 404 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>> | 417 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>> |
| 405 protocol_handlers_; | 418 protocol_handlers_; |
| 406 | 419 |
| 407 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 420 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 408 }; | 421 }; |
| 409 | 422 |
| 410 } // namespace net | 423 } // namespace net |
| 411 | 424 |
| 412 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 425 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |