url_request_context_storage.cc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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
  3. // found in the LICENSE file.
  4. #include "net/url_request/url_request_context_storage.h"
  5. #include <utility>
  6. #include "base/check.h"
  7. #include "net/base/http_user_agent_settings.h"
  8. #include "net/base/network_delegate.h"
  9. #include "net/base/port_util.h"
  10. #include "net/base/proxy_delegate.h"
  11. #include "net/cert/cert_verifier.h"
  12. #include "net/cert/ct_policy_enforcer.h"
  13. #include "net/cert/sct_auditing_delegate.h"
  14. #include "net/cookies/cookie_store.h"
  15. #include "net/dns/host_resolver.h"
  16. #include "net/http/http_auth_handler_factory.h"
  17. #include "net/http/http_network_session.h"
  18. #include "net/http/http_server_properties.h"
  19. #include "net/http/http_transaction_factory.h"
  20. #include "net/http/transport_security_state.h"
  21. #include "net/proxy_resolution/proxy_resolution_service.h"
  22. #include "net/quic/quic_context.h"
  23. #include "net/socket/client_socket_factory.h"
  24. #include "net/ssl/ssl_config_service.h"
  25. #include "net/url_request/url_request_context.h"
  26. #include "net/url_request/url_request_job_factory.h"
  27. #include "net/url_request/url_request_throttler_manager.h"
  28. #if BUILDFLAG(ENABLE_REPORTING)
  29. #include "net/network_error_logging/network_error_logging_service.h"
  30. #include "net/network_error_logging/persistent_reporting_and_nel_store.h"
  31. #include "net/reporting/reporting_service.h"
  32. #endif // BUILDFLAG(ENABLE_REPORTING)
  33. namespace net {
  34. URLRequestContextStorage::URLRequestContextStorage(URLRequestContext* context)
  35. : context_(context) {
  36. DCHECK(context);
  37. }
  38. URLRequestContextStorage::~URLRequestContextStorage() = default;
  39. void URLRequestContextStorage::set_host_resolver(
  40. std::unique_ptr<HostResolver> host_resolver) {
  41. context_->set_host_resolver(host_resolver.get());
  42. host_resolver_ = std::move(host_resolver);
  43. }
  44. void URLRequestContextStorage::set_cert_verifier(
  45. std::unique_ptr<CertVerifier> cert_verifier) {
  46. context_->set_cert_verifier(cert_verifier.get());
  47. cert_verifier_ = std::move(cert_verifier);
  48. }
  49. void URLRequestContextStorage::set_http_auth_handler_factory(
  50. std::unique_ptr<HttpAuthHandlerFactory> http_auth_handler_factory) {
  51. context_->set_http_auth_handler_factory(http_auth_handler_factory.get());
  52. http_auth_handler_factory_ = std::move(http_auth_handler_factory);
  53. }
  54. void URLRequestContextStorage::set_proxy_delegate(
  55. std::unique_ptr<ProxyDelegate> proxy_delegate) {
  56. context_->set_proxy_delegate(proxy_delegate.get());
  57. proxy_delegate_ = std::move(proxy_delegate);
  58. }
  59. void URLRequestContextStorage::set_network_delegate(
  60. std::unique_ptr<NetworkDelegate> network_delegate) {
  61. context_->set_network_delegate(network_delegate.get());
  62. network_delegate_ = std::move(network_delegate);
  63. }
  64. void URLRequestContextStorage::set_proxy_resolution_service(
  65. std::unique_ptr<ProxyResolutionService> proxy_resolution_service) {
  66. context_->set_proxy_resolution_service(proxy_resolution_service.get());
  67. proxy_resolution_service_ = std::move(proxy_resolution_service);
  68. }
  69. void URLRequestContextStorage::set_ssl_config_service(
  70. std::unique_ptr<SSLConfigService> ssl_config_service) {
  71. context_->set_ssl_config_service(ssl_config_service.get());
  72. ssl_config_service_ = std::move(ssl_config_service);
  73. }
  74. void URLRequestContextStorage::set_http_server_properties(
  75. std::unique_ptr<HttpServerProperties> http_server_properties) {
  76. context_->set_http_server_properties(http_server_properties.get());
  77. http_server_properties_ = std::move(http_server_properties);
  78. }
  79. void URLRequestContextStorage::set_cookie_store(
  80. std::unique_ptr<CookieStore> cookie_store) {
  81. context_->set_cookie_store(cookie_store.get());
  82. cookie_store_ = std::move(cookie_store);
  83. }
  84. void URLRequestContextStorage::set_transport_security_state(
  85. std::unique_ptr<TransportSecurityState> transport_security_state) {
  86. context_->set_transport_security_state(transport_security_state.get());
  87. transport_security_state_ = std::move(transport_security_state);
  88. }
  89. void URLRequestContextStorage::set_ct_policy_enforcer(
  90. std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer) {
  91. context_->set_ct_policy_enforcer(ct_policy_enforcer.get());
  92. ct_policy_enforcer_ = std::move(ct_policy_enforcer);
  93. }
  94. void URLRequestContextStorage::set_sct_auditing_delegate(
  95. std::unique_ptr<SCTAuditingDelegate> sct_auditing_delegate) {
  96. context_->set_sct_auditing_delegate(sct_auditing_delegate.get());
  97. sct_auditing_delegate_ = std::move(sct_auditing_delegate);
  98. }
  99. void URLRequestContextStorage::set_http_network_session(
  100. std::unique_ptr<HttpNetworkSession> http_network_session) {
  101. http_network_session_ = std::move(http_network_session);
  102. }
  103. void URLRequestContextStorage::set_http_transaction_factory(
  104. std::unique_ptr<HttpTransactionFactory> http_transaction_factory) {
  105. context_->set_http_transaction_factory(http_transaction_factory.get());
  106. http_transaction_factory_ = std::move(http_transaction_factory);
  107. }
  108. void URLRequestContextStorage::set_job_factory(
  109. std::unique_ptr<URLRequestJobFactory> job_factory) {
  110. context_->set_job_factory(job_factory.get());
  111. job_factory_ = std::move(job_factory);
  112. }
  113. void URLRequestContextStorage::set_throttler_manager(
  114. std::unique_ptr<URLRequestThrottlerManager> throttler_manager) {
  115. context_->set_throttler_manager(throttler_manager.get());
  116. throttler_manager_ = std::move(throttler_manager);
  117. }
  118. void URLRequestContextStorage::set_quic_context(
  119. std::unique_ptr<QuicContext> quic_context) {
  120. context_->set_quic_context(quic_context.get());
  121. quic_context_ = std::move(quic_context);
  122. }
  123. void URLRequestContextStorage::set_http_user_agent_settings(
  124. std::unique_ptr<HttpUserAgentSettings> http_user_agent_settings) {
  125. context_->set_http_user_agent_settings(http_user_agent_settings.get());
  126. http_user_agent_settings_ = std::move(http_user_agent_settings);
  127. }
  128. #if BUILDFLAG(ENABLE_REPORTING)
  129. void URLRequestContextStorage::set_persistent_reporting_and_nel_store(
  130. std::unique_ptr<PersistentReportingAndNelStore>
  131. persistent_reporting_and_nel_store) {
  132. persistent_reporting_and_nel_store_ =
  133. std::move(persistent_reporting_and_nel_store);
  134. }
  135. void URLRequestContextStorage::set_reporting_service(
  136. std::unique_ptr<ReportingService> reporting_service) {
  137. context_->set_reporting_service(reporting_service.get());
  138. reporting_service_ = std::move(reporting_service);
  139. }
  140. void URLRequestContextStorage::set_network_error_logging_service(
  141. std::unique_ptr<NetworkErrorLoggingService> network_error_logging_service) {
  142. context_->set_network_error_logging_service(
  143. network_error_logging_service.get());
  144. network_error_logging_service_ = std::move(network_error_logging_service);
  145. }
  146. #endif // BUILDFLAG(ENABLE_REPORTING)
  147. void URLRequestContextStorage::set_client_socket_factory(
  148. std::unique_ptr<ClientSocketFactory> client_socket_factory) {
  149. client_socket_factory_ = std::move(client_socket_factory);
  150. }
  151. } // namespace net