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

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

Issue 2972223002: Revert https://codereview.chromium.org/2860033003 (Closed)
Patch Set: Created 3 years, 5 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/test/base/testing_io_thread_state.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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include "net/ssl/channel_id_service.h" 103 #include "net/ssl/channel_id_service.h"
104 #include "net/ssl/default_channel_id_store.h" 104 #include "net/ssl/default_channel_id_store.h"
105 #include "net/url_request/data_protocol_handler.h" 105 #include "net/url_request/data_protocol_handler.h"
106 #include "net/url_request/file_protocol_handler.h" 106 #include "net/url_request/file_protocol_handler.h"
107 #include "net/url_request/ftp_protocol_handler.h" 107 #include "net/url_request/ftp_protocol_handler.h"
108 #include "net/url_request/static_http_user_agent_settings.h" 108 #include "net/url_request/static_http_user_agent_settings.h"
109 #include "net/url_request/url_fetcher.h" 109 #include "net/url_request/url_fetcher.h"
110 #include "net/url_request/url_request_context.h" 110 #include "net/url_request/url_request_context.h"
111 #include "net/url_request/url_request_context_builder.h" 111 #include "net/url_request/url_request_context_builder.h"
112 #include "net/url_request/url_request_context_getter.h" 112 #include "net/url_request/url_request_context_getter.h"
113 #include "net/url_request/url_request_context_storage.h"
114 #include "net/url_request/url_request_job_factory_impl.h" 113 #include "net/url_request/url_request_job_factory_impl.h"
115 #include "url/url_constants.h" 114 #include "url/url_constants.h"
116 115
117 #if BUILDFLAG(ENABLE_EXTENSIONS) 116 #if BUILDFLAG(ENABLE_EXTENSIONS)
118 #include "chrome/browser/extensions/event_router_forwarder.h" 117 #include "chrome/browser/extensions/event_router_forwarder.h"
119 #endif 118 #endif
120 119
121 #if defined(USE_NSS_CERTS) 120 #if defined(USE_NSS_CERTS)
122 #include "net/cert_net/nss_ocsp.h" 121 #include "net/cert_net/nss_ocsp.h"
123 #endif 122 #endif
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 SystemURLRequestContext() { 192 SystemURLRequestContext() {
194 #if defined(USE_NSS_CERTS) 193 #if defined(USE_NSS_CERTS)
195 net::SetURLRequestContextForNSSHttpIO(this); 194 net::SetURLRequestContextForNSSHttpIO(this);
196 #endif 195 #endif
197 #if defined(OS_ANDROID) 196 #if defined(OS_ANDROID)
198 net::CertVerifyProcAndroid::SetCertNetFetcher( 197 net::CertVerifyProcAndroid::SetCertNetFetcher(
199 net::CreateCertNetFetcher(this)); 198 net::CreateCertNetFetcher(this));
200 #endif 199 #endif
201 } 200 }
202 201
202 private:
203 ~SystemURLRequestContext() override { 203 ~SystemURLRequestContext() override {
204 AssertNoURLRequests(); 204 AssertNoURLRequests();
205 #if defined(USE_NSS_CERTS) 205 #if defined(USE_NSS_CERTS)
206 net::SetURLRequestContextForNSSHttpIO(NULL); 206 net::SetURLRequestContextForNSSHttpIO(NULL);
207 #endif 207 #endif
208
209 #if defined(OS_ANDROID)
210 net::CertVerifyProcAndroid::ShutdownCertNetFetcher();
211 #endif
212 } 208 }
213
214 private:
215 DISALLOW_COPY_AND_ASSIGN(SystemURLRequestContext);
216 }; 209 };
217 210
218 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( 211 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver(
219 net::NetLog* net_log) { 212 net::NetLog* net_log) {
220 TRACE_EVENT0("startup", "IOThread::CreateGlobalHostResolver"); 213 TRACE_EVENT0("startup", "IOThread::CreateGlobalHostResolver");
221 const base::CommandLine& command_line = 214 const base::CommandLine& command_line =
222 *base::CommandLine::ForCurrentProcess(); 215 *base::CommandLine::ForCurrentProcess();
223 216
224 net::HostResolver::Options options; 217 net::HostResolver::Options options;
225 218
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); 391 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName);
399 #endif 392 #endif
400 #if defined(OS_CHROMEOS) 393 #if defined(OS_CHROMEOS)
401 policy::BrowserPolicyConnectorChromeOS* connector = 394 policy::BrowserPolicyConnectorChromeOS* connector =
402 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 395 g_browser_process->platform_part()->browser_policy_connector_chromeos();
403 allow_gssapi_library_load_ = connector->IsActiveDirectoryManaged(); 396 allow_gssapi_library_load_ = connector->IsActiveDirectoryManaged();
404 #endif 397 #endif
405 pref_proxy_config_tracker_.reset( 398 pref_proxy_config_tracker_.reset(
406 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( 399 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
407 local_state)); 400 local_state));
408 system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService(
409 pref_proxy_config_tracker_.get());
410 ChromeNetworkDelegate::InitializePrefsOnUIThread( 401 ChromeNetworkDelegate::InitializePrefsOnUIThread(
411 &system_enable_referrers_, 402 &system_enable_referrers_,
412 nullptr, 403 nullptr,
413 nullptr, 404 nullptr,
414 nullptr, 405 nullptr,
415 nullptr, 406 nullptr,
416 local_state); 407 local_state);
417 ssl_config_service_manager_.reset( 408 ssl_config_service_manager_.reset(
418 ssl_config::SSLConfigServiceManager::CreateDefaultManager( 409 ssl_config::SSLConfigServiceManager::CreateDefaultManager(
419 local_state, 410 local_state,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 DCHECK_CURRENTLY_ON(BrowserThread::UI); 482 DCHECK_CURRENTLY_ON(BrowserThread::UI);
492 BrowserThread::PostTask( 483 BrowserThread::PostTask(
493 BrowserThread::IO, FROM_HERE, 484 BrowserThread::IO, FROM_HERE,
494 base::BindOnce(&IOThread::ChangedToOnTheRecordOnIOThread, 485 base::BindOnce(&IOThread::ChangedToOnTheRecordOnIOThread,
495 base::Unretained(this))); 486 base::Unretained(this)));
496 } 487 }
497 488
498 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { 489 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() {
499 DCHECK_CURRENTLY_ON(BrowserThread::UI); 490 DCHECK_CURRENTLY_ON(BrowserThread::UI);
500 if (!system_url_request_context_getter_.get()) { 491 if (!system_url_request_context_getter_.get()) {
501 system_url_request_context_getter_ = 492 InitSystemRequestContext();
502 new SystemURLRequestContextGetter(this);
503 } 493 }
504 return system_url_request_context_getter_.get(); 494 return system_url_request_context_getter_.get();
505 } 495 }
506 496
507 void IOThread::Init() { 497 void IOThread::Init() {
508 TRACE_EVENT0("startup", "IOThread::InitAsync"); 498 TRACE_EVENT0("startup", "IOThread::InitAsync");
509 DCHECK_CURRENTLY_ON(BrowserThread::IO); 499 DCHECK_CURRENTLY_ON(BrowserThread::IO);
510 500
511 #if defined(USE_NSS_CERTS) 501 #if defined(USE_NSS_CERTS)
512 net::SetMessageLoopForNSSHttpIO(); 502 net::SetMessageLoopForNSSHttpIO();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer()); 630 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer());
641 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get(); 631 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get();
642 632
643 globals_->ssl_config_service = GetSSLConfigService(); 633 globals_->ssl_config_service = GetSSLConfigService();
644 634
645 CreateDefaultAuthHandlerFactory(); 635 CreateDefaultAuthHandlerFactory();
646 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); 636 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl());
647 // For the ProxyScriptFetcher, we use a direct ProxyService. 637 // For the ProxyScriptFetcher, we use a direct ProxyService.
648 globals_->proxy_script_fetcher_proxy_service = 638 globals_->proxy_script_fetcher_proxy_service =
649 net::ProxyService::CreateDirectWithNetLog(net_log_); 639 net::ProxyService::CreateDirectWithNetLog(net_log_);
640 // In-memory cookie store.
641 globals_->system_cookie_store =
642 content::CreateCookieStore(content::CookieStoreConfig());
643 // In-memory channel ID store.
644 globals_->system_channel_id_service.reset(
645 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL)));
646 globals_->system_cookie_store->SetChannelIDServiceID(
647 globals_->system_channel_id_service->GetUniqueID());
650 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); 648 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService());
651 globals_->host_mapping_rules.reset(new net::HostMappingRules()); 649 globals_->host_mapping_rules.reset(new net::HostMappingRules());
652 params_.host_mapping_rules = globals_->host_mapping_rules.get(); 650 params_.host_mapping_rules = globals_->host_mapping_rules.get();
653 globals_->http_user_agent_settings.reset( 651 globals_->http_user_agent_settings.reset(
654 new net::StaticHttpUserAgentSettings(std::string(), GetUserAgent())); 652 new net::StaticHttpUserAgentSettings(std::string(), GetUserAgent()));
655 if (command_line.HasSwitch(switches::kHostRules)) { 653 if (command_line.HasSwitch(switches::kHostRules)) {
656 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); 654 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString");
657 globals_->host_mapping_rules->SetRulesFromString( 655 globals_->host_mapping_rules->SetRulesFromString(
658 command_line.GetSwitchValueASCII(switches::kHostRules)); 656 command_line.GetSwitchValueASCII(switches::kHostRules));
659 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); 657 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString");
660 } 658 }
661 globals_->enable_brotli = 659 globals_->enable_brotli =
662 base::FeatureList::IsEnabled(features::kBrotliEncoding); 660 base::FeatureList::IsEnabled(features::kBrotliEncoding);
663 params_.enable_token_binding = 661 params_.enable_token_binding =
664 base::FeatureList::IsEnabled(features::kTokenBinding); 662 base::FeatureList::IsEnabled(features::kTokenBinding);
665 663
666 // Check for OS support of TCP FastOpen, and turn it on for all connections if 664 // Check for OS support of TCP FastOpen, and turn it on for all connections if
667 // indicated by user. 665 // indicated by user.
668 // TODO(rch): Make the client socket factory a per-network session instance, 666 // TODO(rch): Make the client socket factory a per-network session instance,
669 // constructed from a NetworkSession::Params, to allow us to move this option 667 // constructed from a NetworkSession::Params, to allow us to move this option
670 // to IOThread::Globals & HttpNetworkSession::Params. 668 // to IOThread::Globals & HttpNetworkSession::Params.
671 bool always_enable_tfo_if_supported = 669 bool always_enable_tfo_if_supported =
672 command_line.HasSwitch(switches::kEnableTcpFastOpen); 670 command_line.HasSwitch(switches::kEnableTcpFastOpen);
673 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_tfo_if_supported); 671 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_tfo_if_supported);
674 672
675 ConfigureParamsFromFieldTrialsAndCommandLine( 673 ConfigureParamsFromFieldTrialsAndCommandLine(
676 command_line, is_quic_allowed_by_policy_, 674 command_line, is_quic_allowed_by_policy_,
677 http_09_on_non_default_ports_enabled_, &params_); 675 http_09_on_non_default_ports_enabled_, &params_);
678 676
677 TRACE_EVENT_BEGIN0("startup",
678 "IOThread::Init:ProxyScriptFetcherRequestContext");
679 globals_->proxy_script_fetcher_context.reset(
680 ConstructProxyScriptFetcherContext(globals_, params_, net_log_));
681 TRACE_EVENT_END0("startup",
682 "IOThread::Init:ProxyScriptFetcherRequestContext");
683
679 #if defined(OS_MACOSX) 684 #if defined(OS_MACOSX)
680 // Start observing Keychain events. This needs to be done on the UI thread, 685 // Start observing Keychain events. This needs to be done on the UI thread,
681 // as Keychain services requires a CFRunLoop. 686 // as Keychain services requires a CFRunLoop.
682 BrowserThread::PostTask(BrowserThread::UI, 687 BrowserThread::PostTask(BrowserThread::UI,
683 FROM_HERE, 688 FROM_HERE,
684 base::Bind(&ObserveKeychainEvents)); 689 base::Bind(&ObserveKeychainEvents));
685 #endif 690 #endif
686 691
692 // InitSystemRequestContext turns right around and posts a task back
693 // to the IO thread, so we can't let it run until we know the IO
694 // thread has started.
695 //
696 // Note that since we are at BrowserThread::Init time, the UI thread
697 // is blocked waiting for the thread to start. Therefore, posting
698 // this task to the main thread's message loop here is guaranteed to
699 // get it onto the message loop while the IOThread object still
700 // exists. However, the message might not be processed on the UI
701 // thread until after IOThread is gone, so use a weak pointer.
702 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
703 base::BindOnce(&IOThread::InitSystemRequestContext,
704 weak_factory_.GetWeakPtr()));
705
687 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) 706 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
688 // Record how common CPUs with broken NEON units are. See 707 // Record how common CPUs with broken NEON units are. See
689 // https://crbug.com/341598. 708 // https://crbug.com/341598.
690 crypto::EnsureOpenSSLInit(); 709 crypto::EnsureOpenSSLInit();
691 UMA_HISTOGRAM_BOOLEAN("Net.HasBrokenNEON", CRYPTO_has_broken_NEON()); 710 UMA_HISTOGRAM_BOOLEAN("Net.HasBrokenNEON", CRYPTO_has_broken_NEON());
692 #endif 711 #endif
693
694 ConstructSystemRequestContext();
695 } 712 }
696 713
697 void IOThread::CleanUp() { 714 void IOThread::CleanUp() {
698 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); 715 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks();
699 716
700 #if defined(USE_NSS_CERTS) 717 #if defined(USE_NSS_CERTS)
701 net::ShutdownNSSHttpIO(); 718 net::ShutdownNSSHttpIO();
702 #endif 719 #endif
703 720
721 #if defined(OS_ANDROID)
722 net::CertVerifyProcAndroid::ShutdownCertNetFetcher();
723 #endif
724
704 system_url_request_context_getter_ = NULL; 725 system_url_request_context_getter_ = NULL;
705 726
706 // Unlink the ct_tree_tracker_ from the global cert_transparency_verifier 727 // Unlink the ct_tree_tracker_ from the global cert_transparency_verifier
707 // and unregister it from new STH notifications so it will take no actions 728 // and unregister it from new STH notifications so it will take no actions
708 // on anything observed during CleanUp process. 729 // on anything observed during CleanUp process.
709 // 730 globals()->cert_transparency_verifier->SetObserver(nullptr);
710 // Null checks are just for tests that use TestingIOThreadState. 731 UnregisterSTHObserver(ct_tree_tracker_.get());
711 if (globals()->cert_transparency_verifier) 732
712 globals()->cert_transparency_verifier->SetObserver(nullptr); 733 ct_tree_tracker_.reset();
713 if (ct_tree_tracker_.get()) {
714 UnregisterSTHObserver(ct_tree_tracker_.get());
715 ct_tree_tracker_.reset();
716 }
717 734
718 // Release objects that the net::URLRequestContext could have been pointing 735 // Release objects that the net::URLRequestContext could have been pointing
719 // to. 736 // to.
720 737
721 // Shutdown the HistogramWatcher on the IO thread. 738 // Shutdown the HistogramWatcher on the IO thread.
722 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); 739 net::NetworkChangeNotifier::ShutdownHistogramWatcher();
723 740
724 // This must be reset before the ChromeNetLog is destroyed. 741 // This must be reset before the ChromeNetLog is destroyed.
725 network_change_observer_.reset(); 742 network_change_observer_.reset();
726 743
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 host_cache->ClearForHosts(host_filter); 829 host_cache->ClearForHosts(host_filter);
813 } 830 }
814 831
815 const net::HttpNetworkSession::Params& IOThread::NetworkSessionParams() const { 832 const net::HttpNetworkSession::Params& IOThread::NetworkSessionParams() const {
816 return params_; 833 return params_;
817 } 834 }
818 835
819 void IOThread::DisableQuic() { 836 void IOThread::DisableQuic() {
820 params_.enable_quic = false; 837 params_.enable_quic = false;
821 838
822 if (globals_->system_request_context_storage) 839 if (globals_->system_http_network_session)
823 globals_->system_request_context_storage->http_network_session() 840 globals_->system_http_network_session->DisableQuic();
824 ->DisableQuic();
825 841
826 if (globals_->proxy_script_fetcher_http_network_session) 842 if (globals_->proxy_script_fetcher_http_network_session)
827 globals_->proxy_script_fetcher_http_network_session->DisableQuic(); 843 globals_->proxy_script_fetcher_http_network_session->DisableQuic();
828 } 844 }
829 845
830 base::TimeTicks IOThread::creation_time() const { 846 base::TimeTicks IOThread::creation_time() const {
831 return creation_time_; 847 return creation_time_;
832 } 848 }
833 849
834 net::SSLConfigService* IOThread::GetSSLConfigService() { 850 net::SSLConfigService* IOThread::GetSSLConfigService() {
835 return ssl_config_service_manager_->Get(); 851 return ssl_config_service_manager_->Get();
836 } 852 }
837 853
838 void IOThread::ChangedToOnTheRecordOnIOThread() { 854 void IOThread::ChangedToOnTheRecordOnIOThread() {
839 DCHECK_CURRENTLY_ON(BrowserThread::IO); 855 DCHECK_CURRENTLY_ON(BrowserThread::IO);
840 856
841 // Clear the host cache to avoid showing entries from the OTR session 857 // Clear the host cache to avoid showing entries from the OTR session
842 // in about:net-internals. 858 // in about:net-internals.
843 ClearHostCache(base::Callback<bool(const std::string&)>()); 859 ClearHostCache(base::Callback<bool(const std::string&)>());
844 } 860 }
845 861
862 void IOThread::InitSystemRequestContext() {
863 if (system_url_request_context_getter_.get())
864 return;
865 // If we're in unit_tests, IOThread may not be run.
866 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO))
867 return;
868 system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService(
869 pref_proxy_config_tracker_.get());
870 system_url_request_context_getter_ =
871 new SystemURLRequestContextGetter(this);
872 // Safe to post an unretained this pointer, since IOThread is
873 // guaranteed to outlive the IO BrowserThread.
874 BrowserThread::PostTask(
875 BrowserThread::IO, FROM_HERE,
876 base::BindOnce(&IOThread::InitSystemRequestContextOnIOThread,
877 base::Unretained(this)));
878 }
879
880 void IOThread::InitSystemRequestContextOnIOThread() {
881 DCHECK_CURRENTLY_ON(BrowserThread::IO);
882 DCHECK(!globals_->system_proxy_service.get());
883 DCHECK(system_proxy_config_service_.get());
884
885 const base::CommandLine& command_line =
886 *base::CommandLine::ForCurrentProcess();
887 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService(
888 net_log_, globals_->proxy_script_fetcher_context.get(),
889 globals_->system_network_delegate.get(),
890 std::move(system_proxy_config_service_), command_line,
891 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled());
892
893 globals_->system_request_context.reset(
894 ConstructSystemRequestContext(globals_, params_, net_log_));
895 }
896
846 void IOThread::UpdateDnsClientEnabled() { 897 void IOThread::UpdateDnsClientEnabled() {
847 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 898 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
848 } 899 }
849 900
850 void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) { 901 void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) {
851 chrome_browser_net::GetGlobalSTHDistributor()->RegisterObserver(observer); 902 chrome_browser_net::GetGlobalSTHDistributor()->RegisterObserver(observer);
852 } 903 }
853 904
854 void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) { 905 void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) {
855 chrome_browser_net::GetGlobalSTHDistributor()->UnregisterObserver(observer); 906 chrome_browser_net::GetGlobalSTHDistributor()->UnregisterObserver(observer);
856 } 907 }
857 908
858 bool IOThread::WpadQuickCheckEnabled() const { 909 bool IOThread::WpadQuickCheckEnabled() const {
859 return quick_check_enabled_.GetValue(); 910 return quick_check_enabled_.GetValue();
860 } 911 }
861 912
862 bool IOThread::PacHttpsUrlStrippingEnabled() const { 913 bool IOThread::PacHttpsUrlStrippingEnabled() const {
863 return pac_https_url_stripping_enabled_.GetValue(); 914 return pac_https_url_stripping_enabled_.GetValue();
864 } 915 }
865 916
866 void IOThread::ConstructSystemRequestContext() { 917 // static
867 globals_->system_request_context = 918 net::URLRequestContext* IOThread::ConstructSystemRequestContext(
868 base::MakeUnique<SystemURLRequestContext>(); 919 IOThread::Globals* globals,
869 net::URLRequestContext* context = globals_->system_request_context.get(); 920 const net::HttpNetworkSession::Params& params,
870 globals_->system_request_context_storage = 921 net::NetLog* net_log) {
871 base::MakeUnique<net::URLRequestContextStorage>(context); 922 net::URLRequestContext* context = new SystemURLRequestContext;
872 net::URLRequestContextStorage* context_storage =
873 globals_->system_request_context_storage.get();
874 923
875 context->set_network_quality_estimator( 924 context->set_network_quality_estimator(
876 globals_->network_quality_estimator.get()); 925 globals->network_quality_estimator.get());
877 context->set_enable_brotli(globals_->enable_brotli); 926 context->set_enable_brotli(globals->enable_brotli);
878 context->set_name("system"); 927 context->set_name("system");
879 928
880 context->set_http_user_agent_settings( 929 context->set_http_user_agent_settings(
881 globals_->http_user_agent_settings.get()); 930 globals->http_user_agent_settings.get());
882 context->set_network_delegate(globals_->system_network_delegate.get()); 931 context->set_network_delegate(globals->system_network_delegate.get());
883 context->set_net_log(net_log_); 932 context->set_net_log(net_log);
884 context->set_host_resolver(globals_->host_resolver.get()); 933 context->set_host_resolver(globals->host_resolver.get());
934 context->set_proxy_service(globals->system_proxy_service.get());
935 context->set_ssl_config_service(globals->ssl_config_service.get());
936 context->set_http_auth_handler_factory(
937 globals->http_auth_handler_factory.get());
885 938
886 context->set_ssl_config_service(globals_->ssl_config_service.get()); 939 context->set_cookie_store(globals->system_cookie_store.get());
887 context->set_http_auth_handler_factory( 940 context->set_channel_id_service(
888 globals_->http_auth_handler_factory.get()); 941 globals->system_channel_id_service.get());
942 context->set_transport_security_state(
943 globals->transport_security_state.get());
889 944
890 // In-memory cookie store. 945 context->set_http_server_properties(globals->http_server_properties.get());
891 context_storage->set_cookie_store(
892 content::CreateCookieStore(content::CookieStoreConfig()));
893 // In-memory channel ID store.
894 context_storage->set_channel_id_service(
895 base::MakeUnique<net::ChannelIDService>(
896 new net::DefaultChannelIDStore(nullptr)));
897 context->cookie_store()->SetChannelIDServiceID(
898 context->channel_id_service()->GetUniqueID());
899 946
900 context->set_transport_security_state( 947 context->set_cert_verifier(globals->cert_verifier.get());
901 globals_->transport_security_state.get()); 948 context->set_cert_transparency_verifier(
949 globals->cert_transparency_verifier.get());
950 context->set_ct_policy_enforcer(globals->ct_policy_enforcer.get());
902 951
903 context->set_http_server_properties(globals_->http_server_properties.get()); 952 net::HttpNetworkSession::Params system_params(params);
904
905 context->set_cert_verifier(globals_->cert_verifier.get());
906 context->set_cert_transparency_verifier(
907 globals_->cert_transparency_verifier.get());
908 context->set_ct_policy_enforcer(globals_->ct_policy_enforcer.get());
909
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 =
918 *base::CommandLine::ForCurrentProcess();
919 context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService(
920 net_log_, globals_->proxy_script_fetcher_context.get(),
921 globals_->system_network_delegate.get(),
922 std::move(system_proxy_config_service_), command_line,
923 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled()));
924
925 net::HttpNetworkSession::Params system_params(params_);
926 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( 953 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
927 context, &system_params); 954 context, &system_params);
928 955
929 context_storage->set_http_network_session( 956 globals->system_http_network_session.reset(
930 base::MakeUnique<net::HttpNetworkSession>(system_params)); 957 new net::HttpNetworkSession(system_params));
931 context_storage->set_http_transaction_factory( 958 globals->system_http_transaction_factory.reset(
932 base::MakeUnique<net::HttpNetworkLayer>( 959 new net::HttpNetworkLayer(globals->system_http_network_session.get()));
933 context_storage->http_network_session()));
934 960
935 context_storage->set_job_factory( 961 context->set_http_transaction_factory(
936 base::MakeUnique<net::URLRequestJobFactoryImpl>()); 962 globals->system_http_transaction_factory.get());
963
964 globals->system_url_request_job_factory.reset(
965 new net::URLRequestJobFactoryImpl());
966 context->set_job_factory(globals->system_url_request_job_factory.get());
967
968 return context;
937 } 969 }
938 970
939 // static 971 // static
940 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( 972 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine(
941 const base::CommandLine& command_line, 973 const base::CommandLine& command_line,
942 bool is_quic_allowed_by_policy, 974 bool is_quic_allowed_by_policy,
943 bool http_09_on_non_default_ports_enabled, 975 bool http_09_on_non_default_ports_enabled,
944 net::HttpNetworkSession::Params* params) { 976 net::HttpNetworkSession::Params* params) {
945 std::string quic_user_agent_id = chrome::GetChannelString(); 977 std::string quic_user_agent_id = chrome::GetChannelString();
946 if (!quic_user_agent_id.empty()) 978 if (!quic_user_agent_id.empty())
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 globals->cert_transparency_verifier.get()); 1077 globals->cert_transparency_verifier.get());
1046 context->set_ct_policy_enforcer(globals->ct_policy_enforcer.get()); 1078 context->set_ct_policy_enforcer(globals->ct_policy_enforcer.get());
1047 context->set_ssl_config_service(globals->ssl_config_service.get()); 1079 context->set_ssl_config_service(globals->ssl_config_service.get());
1048 context->set_http_auth_handler_factory( 1080 context->set_http_auth_handler_factory(
1049 globals->http_auth_handler_factory.get()); 1081 globals->http_auth_handler_factory.get());
1050 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); 1082 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
1051 1083
1052 context->set_job_factory( 1084 context->set_job_factory(
1053 globals->proxy_script_fetcher_url_request_job_factory.get()); 1085 globals->proxy_script_fetcher_url_request_job_factory.get());
1054 1086
1055 context->set_cookie_store(globals->system_request_context->cookie_store()); 1087 context->set_cookie_store(globals->system_cookie_store.get());
1056 context->set_channel_id_service( 1088 context->set_channel_id_service(
1057 globals->system_request_context->channel_id_service()); 1089 globals->system_channel_id_service.get());
1058 context->set_network_delegate(globals->system_network_delegate.get()); 1090 context->set_network_delegate(globals->system_network_delegate.get());
1059 context->set_http_user_agent_settings( 1091 context->set_http_user_agent_settings(
1060 globals->http_user_agent_settings.get()); 1092 globals->http_user_agent_settings.get());
1061 context->set_http_server_properties(globals->http_server_properties.get()); 1093 context->set_http_server_properties(globals->http_server_properties.get());
1062 1094
1063 context->set_enable_brotli(globals->enable_brotli); 1095 context->set_enable_brotli(globals->enable_brotli);
1064 1096
1065 net::HttpNetworkSession::Params session_params(params); 1097 net::HttpNetworkSession::Params session_params(params);
1066 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( 1098 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
1067 context, &session_params); 1099 context, &session_params);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1131
1100 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 1132 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1101 // system URLRequestContext too. There's no reason this should be tied to a 1133 // system URLRequestContext too. There's no reason this should be tied to a
1102 // profile. 1134 // profile.
1103 return context; 1135 return context;
1104 } 1136 }
1105 1137
1106 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { 1138 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() {
1107 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); 1139 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread);
1108 } 1140 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/test/base/testing_io_thread_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698