| 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 #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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 std::string path_str; | 174 std::string path_str; |
| 175 env->GetVar("SSLKEYLOGFILE", &path_str); | 175 env->GetVar("SSLKEYLOGFILE", &path_str); |
| 176 #if defined(OS_WIN) | 176 #if defined(OS_WIN) |
| 177 // base::Environment returns environment variables in UTF-8 on Windows. | 177 // base::Environment returns environment variables in UTF-8 on Windows. |
| 178 return base::FilePath(base::UTF8ToUTF16(path_str)); | 178 return base::FilePath(base::UTF8ToUTF16(path_str)); |
| 179 #else | 179 #else |
| 180 return base::FilePath(path_str); | 180 return base::FilePath(path_str); |
| 181 #endif | 181 #endif |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Used for the "system" URLRequestContext. | |
| 185 class SystemURLRequestContext : public net::URLRequestContext { | |
| 186 public: | |
| 187 SystemURLRequestContext() { | |
| 188 #if defined(USE_NSS_CERTS) | |
| 189 net::SetURLRequestContextForNSSHttpIO(this); | |
| 190 #endif | |
| 191 #if defined(OS_ANDROID) | |
| 192 net::CertVerifyProcAndroid::SetCertNetFetcher( | |
| 193 net::CreateCertNetFetcher(this)); | |
| 194 #endif | |
| 195 } | |
| 196 | |
| 197 ~SystemURLRequestContext() override { | |
| 198 AssertNoURLRequests(); | |
| 199 #if defined(USE_NSS_CERTS) | |
| 200 net::SetURLRequestContextForNSSHttpIO(NULL); | |
| 201 #endif | |
| 202 | |
| 203 #if defined(OS_ANDROID) | |
| 204 net::CertVerifyProcAndroid::ShutdownCertNetFetcher(); | |
| 205 #endif | |
| 206 } | |
| 207 | |
| 208 private: | |
| 209 DISALLOW_COPY_AND_ASSIGN(SystemURLRequestContext); | |
| 210 }; | |
| 211 | |
| 212 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( | 184 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( |
| 213 net::NetLog* net_log) { | 185 net::NetLog* net_log) { |
| 214 TRACE_EVENT0("startup", "IOThread::CreateGlobalHostResolver"); | 186 TRACE_EVENT0("startup", "IOThread::CreateGlobalHostResolver"); |
| 215 const base::CommandLine& command_line = | 187 const base::CommandLine& command_line = |
| 216 *base::CommandLine::ForCurrentProcess(); | 188 *base::CommandLine::ForCurrentProcess(); |
| 217 | 189 |
| 218 net::HostResolver::Options options; | 190 net::HostResolver::Options options; |
| 219 std::unique_ptr<net::HostResolver> global_host_resolver; | 191 std::unique_ptr<net::HostResolver> global_host_resolver; |
| 220 #if defined OS_CHROMEOS | 192 #if defined OS_CHROMEOS |
| 221 global_host_resolver = | 193 global_host_resolver = |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 if (globals()->system_request_context) { | 609 if (globals()->system_request_context) { |
| 638 globals() | 610 globals() |
| 639 ->system_request_context->cert_transparency_verifier() | 611 ->system_request_context->cert_transparency_verifier() |
| 640 ->SetObserver(nullptr); | 612 ->SetObserver(nullptr); |
| 641 } | 613 } |
| 642 if (ct_tree_tracker_.get()) { | 614 if (ct_tree_tracker_.get()) { |
| 643 UnregisterSTHObserver(ct_tree_tracker_.get()); | 615 UnregisterSTHObserver(ct_tree_tracker_.get()); |
| 644 ct_tree_tracker_.reset(); | 616 ct_tree_tracker_.reset(); |
| 645 } | 617 } |
| 646 | 618 |
| 647 if (globals_->system_request_context) | 619 if (globals_->system_request_context) { |
| 648 globals_->system_request_context->proxy_service()->OnShutdown(); | 620 globals_->system_request_context->proxy_service()->OnShutdown(); |
| 649 | 621 |
| 622 #if defined(USE_NSS_CERTS) |
| 623 net::SetURLRequestContextForNSSHttpIO(nullptr); |
| 624 #endif |
| 625 |
| 626 #if defined(OS_ANDROID) |
| 627 net::CertVerifyProcAndroid::ShutdownCertNetFetcher(); |
| 628 #endif |
| 629 } |
| 630 |
| 650 // Release objects that the net::URLRequestContext could have been pointing | 631 // Release objects that the net::URLRequestContext could have been pointing |
| 651 // to. | 632 // to. |
| 652 | 633 |
| 653 // Shutdown the HistogramWatcher on the IO thread. | 634 // Shutdown the HistogramWatcher on the IO thread. |
| 654 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 635 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 655 | 636 |
| 656 // This must be reset before the ChromeNetLog is destroyed. | 637 // This must be reset before the ChromeNetLog is destroyed. |
| 657 network_change_observer_.reset(); | 638 network_change_observer_.reset(); |
| 658 | 639 |
| 659 system_proxy_config_service_.reset(); | 640 system_proxy_config_service_.reset(); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 861 |
| 881 builder.set_data_enabled(true); | 862 builder.set_data_enabled(true); |
| 882 builder.set_file_enabled(true); | 863 builder.set_file_enabled(true); |
| 883 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) | 864 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) |
| 884 builder.set_ftp_enabled(true); | 865 builder.set_ftp_enabled(true); |
| 885 #endif | 866 #endif |
| 886 | 867 |
| 887 builder.DisableHttpCache(); | 868 builder.DisableHttpCache(); |
| 888 | 869 |
| 889 globals_->system_request_context = builder.Build(); | 870 globals_->system_request_context = builder.Build(); |
| 871 |
| 872 #if defined(USE_NSS_CERTS) |
| 873 net::SetURLRequestContextForNSSHttpIO(globals_->system_request_context.get()); |
| 874 #endif |
| 875 #if defined(OS_ANDROID) |
| 876 net::CertVerifyProcAndroid::SetCertNetFetcher( |
| 877 net::CreateCertNetFetcher(globals_->system_request_context.get())); |
| 878 #endif |
| 890 } | 879 } |
| 891 | 880 |
| 892 // static | 881 // static |
| 893 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( | 882 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( |
| 894 const base::CommandLine& command_line, | 883 const base::CommandLine& command_line, |
| 895 bool is_quic_allowed_by_policy, | 884 bool is_quic_allowed_by_policy, |
| 896 bool http_09_on_non_default_ports_enabled, | 885 bool http_09_on_non_default_ports_enabled, |
| 897 net::HttpNetworkSession::Params* params) { | 886 net::HttpNetworkSession::Params* params) { |
| 898 std::string quic_user_agent_id = chrome::GetChannelString(); | 887 std::string quic_user_agent_id = chrome::GetChannelString(); |
| 899 if (!quic_user_agent_id.empty()) | 888 if (!quic_user_agent_id.empty()) |
| 900 quic_user_agent_id.push_back(' '); | 889 quic_user_agent_id.push_back(' '); |
| 901 quic_user_agent_id.append( | 890 quic_user_agent_id.append( |
| 902 version_info::GetProductNameAndVersionForUserAgent()); | 891 version_info::GetProductNameAndVersionForUserAgent()); |
| 903 quic_user_agent_id.push_back(' '); | 892 quic_user_agent_id.push_back(' '); |
| 904 quic_user_agent_id.append(content::BuildOSCpuInfo()); | 893 quic_user_agent_id.append(content::BuildOSCpuInfo()); |
| 905 | 894 |
| 906 network_session_configurator::ParseCommandLineAndFieldTrials( | 895 network_session_configurator::ParseCommandLineAndFieldTrials( |
| 907 command_line, !is_quic_allowed_by_policy, quic_user_agent_id, params); | 896 command_line, !is_quic_allowed_by_policy, quic_user_agent_id, params); |
| 908 | 897 |
| 909 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) | 898 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) |
| 910 net::URLFetcher::SetIgnoreCertificateRequests(true); | 899 net::URLFetcher::SetIgnoreCertificateRequests(true); |
| 911 | 900 |
| 912 params->http_09_on_non_default_ports_enabled = | 901 params->http_09_on_non_default_ports_enabled = |
| 913 http_09_on_non_default_ports_enabled; | 902 http_09_on_non_default_ports_enabled; |
| 914 } | 903 } |
| 915 | 904 |
| 916 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { | 905 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { |
| 917 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); | 906 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); |
| 918 } | 907 } |
| OLD | NEW |