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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 2852133002: Remove PAC-fetching URLRequestContext. (Closed)
Patch Set: More upstream merge conflicts! Fun! Created 3 years, 7 months 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
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // Register the ct_tree_tracker_ as observer for verified SCTs. 637 // Register the ct_tree_tracker_ as observer for verified SCTs.
638 globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get()); 638 globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get());
639 639
640 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer()); 640 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer());
641 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get(); 641 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get();
642 642
643 globals_->ssl_config_service = GetSSLConfigService(); 643 globals_->ssl_config_service = GetSSLConfigService();
644 644
645 CreateDefaultAuthHandlerFactory(); 645 CreateDefaultAuthHandlerFactory();
646 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); 646 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl());
647 // For the ProxyScriptFetcher, we use a direct ProxyService.
648 globals_->proxy_script_fetcher_proxy_service =
649 net::ProxyService::CreateDirectWithNetLog(net_log_);
650 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); 647 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService());
651 globals_->host_mapping_rules.reset(new net::HostMappingRules()); 648 globals_->host_mapping_rules.reset(new net::HostMappingRules());
652 if (command_line.HasSwitch(switches::kHostRules)) { 649 if (command_line.HasSwitch(switches::kHostRules)) {
653 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); 650 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString");
654 globals_->host_mapping_rules->SetRulesFromString( 651 globals_->host_mapping_rules->SetRulesFromString(
655 command_line.GetSwitchValueASCII(switches::kHostRules)); 652 command_line.GetSwitchValueASCII(switches::kHostRules));
656 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); 653 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString");
657 } 654 }
658 params_.host_mapping_rules = *globals_->host_mapping_rules.get(); 655 params_.host_mapping_rules = *globals_->host_mapping_rules.get();
659 globals_->http_user_agent_settings.reset( 656 globals_->http_user_agent_settings.reset(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // on anything observed during CleanUp process. 705 // on anything observed during CleanUp process.
709 // 706 //
710 // Null checks are just for tests that use TestingIOThreadState. 707 // Null checks are just for tests that use TestingIOThreadState.
711 if (globals()->cert_transparency_verifier) 708 if (globals()->cert_transparency_verifier)
712 globals()->cert_transparency_verifier->SetObserver(nullptr); 709 globals()->cert_transparency_verifier->SetObserver(nullptr);
713 if (ct_tree_tracker_.get()) { 710 if (ct_tree_tracker_.get()) {
714 UnregisterSTHObserver(ct_tree_tracker_.get()); 711 UnregisterSTHObserver(ct_tree_tracker_.get());
715 ct_tree_tracker_.reset(); 712 ct_tree_tracker_.reset();
716 } 713 }
717 714
715 if (globals_->system_request_context)
716 globals_->system_request_context->proxy_service()->OnShutdown();
717
718 // Release objects that the net::URLRequestContext could have been pointing 718 // Release objects that the net::URLRequestContext could have been pointing
719 // to. 719 // to.
720 720
721 // Shutdown the HistogramWatcher on the IO thread. 721 // Shutdown the HistogramWatcher on the IO thread.
722 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); 722 net::NetworkChangeNotifier::ShutdownHistogramWatcher();
723 723
724 // This must be reset before the ChromeNetLog is destroyed. 724 // This must be reset before the ChromeNetLog is destroyed.
725 network_change_observer_.reset(); 725 network_change_observer_.reset();
726 726
727 system_proxy_config_service_.reset(); 727 system_proxy_config_service_.reset();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 const net::HttpNetworkSession::Params& IOThread::NetworkSessionParams() const { 815 const net::HttpNetworkSession::Params& IOThread::NetworkSessionParams() const {
816 return params_; 816 return params_;
817 } 817 }
818 818
819 void IOThread::DisableQuic() { 819 void IOThread::DisableQuic() {
820 params_.enable_quic = false; 820 params_.enable_quic = false;
821 821
822 if (globals_->system_request_context_storage) 822 if (globals_->system_request_context_storage)
823 globals_->system_request_context_storage->http_network_session() 823 globals_->system_request_context_storage->http_network_session()
824 ->DisableQuic(); 824 ->DisableQuic();
825
826 if (globals_->proxy_script_fetcher_http_network_session)
827 globals_->proxy_script_fetcher_http_network_session->DisableQuic();
828 } 825 }
829 826
830 base::TimeTicks IOThread::creation_time() const { 827 base::TimeTicks IOThread::creation_time() const {
831 return creation_time_; 828 return creation_time_;
832 } 829 }
833 830
834 net::SSLConfigService* IOThread::GetSSLConfigService() { 831 net::SSLConfigService* IOThread::GetSSLConfigService() {
835 return ssl_config_service_manager_->Get(); 832 return ssl_config_service_manager_->Get();
836 } 833 }
837 834
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 context->set_transport_security_state( 897 context->set_transport_security_state(
901 globals_->transport_security_state.get()); 898 globals_->transport_security_state.get());
902 899
903 context->set_http_server_properties(globals_->http_server_properties.get()); 900 context->set_http_server_properties(globals_->http_server_properties.get());
904 901
905 context->set_cert_verifier(globals_->cert_verifier.get()); 902 context->set_cert_verifier(globals_->cert_verifier.get());
906 context->set_cert_transparency_verifier( 903 context->set_cert_transparency_verifier(
907 globals_->cert_transparency_verifier.get()); 904 globals_->cert_transparency_verifier.get());
908 context->set_ct_policy_enforcer(globals_->ct_policy_enforcer.get()); 905 context->set_ct_policy_enforcer(globals_->ct_policy_enforcer.get());
909 906
910 TRACE_EVENT_BEGIN0("startup",
911 "IOThread::Init:ProxyScriptFetcherRequestContext");
912 globals_->proxy_script_fetcher_context.reset(
913 ConstructProxyScriptFetcherContext(globals_, params_, net_log_));
914 TRACE_EVENT_END0("startup",
915 "IOThread::Init:ProxyScriptFetcherRequestContext");
916
917 const base::CommandLine& command_line = 907 const base::CommandLine& command_line =
918 *base::CommandLine::ForCurrentProcess(); 908 *base::CommandLine::ForCurrentProcess();
919 context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService( 909 context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService(
920 net_log_, globals_->proxy_script_fetcher_context.get(), 910 net_log_, context, globals_->system_network_delegate.get(),
921 globals_->system_network_delegate.get(),
922 std::move(system_proxy_config_service_), command_line, 911 std::move(system_proxy_config_service_), command_line,
923 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled())); 912 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled()));
924 913
925 net::HttpNetworkSession::Params system_params(params_); 914 net::HttpNetworkSession::Params system_params(params_);
926 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( 915 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
927 context, &system_params); 916 context, &system_params);
928 917
929 context_storage->set_http_network_session( 918 context_storage->set_http_network_session(
930 base::MakeUnique<net::HttpNetworkSession>(system_params)); 919 base::MakeUnique<net::HttpNetworkSession>(system_params));
931 context_storage->set_http_transaction_factory( 920 context_storage->set_http_transaction_factory(
932 base::MakeUnique<net::HttpNetworkLayer>( 921 base::MakeUnique<net::HttpNetworkLayer>(
933 context_storage->http_network_session())); 922 context_storage->http_network_session()));
934 923
935 context_storage->set_job_factory( 924 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
936 base::MakeUnique<net::URLRequestJobFactoryImpl>()); 925 new net::URLRequestJobFactoryImpl());
926
927 job_factory->SetProtocolHandler(url::kDataScheme,
928 base::MakeUnique<net::DataProtocolHandler>());
929 job_factory->SetProtocolHandler(
930 url::kFileScheme,
931 base::MakeUnique<net::FileProtocolHandler>(
932 base::CreateTaskRunnerWithTraits(
933 {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
934 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
935 #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
936 job_factory->SetProtocolHandler(
937 url::kFtpScheme,
938 net::FtpProtocolHandler::Create(globals_->host_resolver.get()));
939 #endif
940
941 context_storage->set_job_factory(std::move(job_factory));
937 } 942 }
938 943
939 // static 944 // static
940 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( 945 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine(
941 const base::CommandLine& command_line, 946 const base::CommandLine& command_line,
942 bool is_quic_allowed_by_policy, 947 bool is_quic_allowed_by_policy,
943 bool http_09_on_non_default_ports_enabled, 948 bool http_09_on_non_default_ports_enabled,
944 net::HttpNetworkSession::Params* params) { 949 net::HttpNetworkSession::Params* params) {
945 std::string quic_user_agent_id = chrome::GetChannelString(); 950 std::string quic_user_agent_id = chrome::GetChannelString();
946 if (!quic_user_agent_id.empty()) 951 if (!quic_user_agent_id.empty())
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 } 1028 }
1024 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 1029 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
1025 params->testing_fixed_https_port = 1030 params->testing_fixed_https_port =
1026 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); 1031 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort);
1027 } 1032 }
1028 1033
1029 params->http_09_on_non_default_ports_enabled = 1034 params->http_09_on_non_default_ports_enabled =
1030 http_09_on_non_default_ports_enabled; 1035 http_09_on_non_default_ports_enabled;
1031 } 1036 }
1032 1037
1033 // static
1034 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext(
1035 IOThread::Globals* globals,
1036 const net::HttpNetworkSession::Params& params,
1037 net::NetLog* net_log) {
1038 net::URLRequestContext* context = new net::URLRequestContext;
1039 context->set_net_log(net_log);
1040 context->set_host_resolver(globals->host_resolver.get());
1041 context->set_cert_verifier(globals->cert_verifier.get());
1042 context->set_transport_security_state(
1043 globals->transport_security_state.get());
1044 context->set_cert_transparency_verifier(
1045 globals->cert_transparency_verifier.get());
1046 context->set_ct_policy_enforcer(globals->ct_policy_enforcer.get());
1047 context->set_ssl_config_service(globals->ssl_config_service.get());
1048 context->set_http_auth_handler_factory(
1049 globals->http_auth_handler_factory.get());
1050 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
1051
1052 context->set_job_factory(
1053 globals->proxy_script_fetcher_url_request_job_factory.get());
1054
1055 context->set_cookie_store(globals->system_request_context->cookie_store());
1056 context->set_channel_id_service(
1057 globals->system_request_context->channel_id_service());
1058 context->set_network_delegate(globals->system_network_delegate.get());
1059 context->set_http_user_agent_settings(
1060 globals->http_user_agent_settings.get());
1061 context->set_http_server_properties(globals->http_server_properties.get());
1062
1063 context->set_enable_brotli(globals->enable_brotli);
1064
1065 net::HttpNetworkSession::Params session_params(params);
1066 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
1067 context, &session_params);
1068
1069 globals->proxy_script_fetcher_http_network_session.reset(
1070 new net::HttpNetworkSession(session_params));
1071 globals->proxy_script_fetcher_http_transaction_factory.reset(
1072 new net::HttpNetworkLayer(
1073 globals->proxy_script_fetcher_http_network_session.get()));
1074 context->set_name("proxy");
1075 context->set_http_transaction_factory(
1076 globals->proxy_script_fetcher_http_transaction_factory.get());
1077
1078 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
1079 new net::URLRequestJobFactoryImpl());
1080
1081 job_factory->SetProtocolHandler(url::kDataScheme,
1082 base::MakeUnique<net::DataProtocolHandler>());
1083 job_factory->SetProtocolHandler(
1084 url::kFileScheme,
1085 base::MakeUnique<net::FileProtocolHandler>(
1086 base::CreateTaskRunnerWithTraits(
1087 {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
1088 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
1089 #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
1090 job_factory->SetProtocolHandler(
1091 url::kFtpScheme,
1092 net::FtpProtocolHandler::Create(globals->host_resolver.get()));
1093 #endif
1094 globals->proxy_script_fetcher_url_request_job_factory =
1095 std::move(job_factory);
1096
1097 context->set_job_factory(
1098 globals->proxy_script_fetcher_url_request_job_factory.get());
1099
1100 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1101 // system URLRequestContext too. There's no reason this should be tied to a
1102 // profile.
1103 return context;
1104 }
1105
1106 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { 1038 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() {
1107 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); 1039 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread);
1108 } 1040 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698