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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 #endif // defined(OS_ANDROID) | 546 #endif // defined(OS_ANDROID) |
547 | 547 |
548 globals_->data_use_ascriber = | 548 globals_->data_use_ascriber = |
549 base::MakeUnique<data_use_measurement::ChromeDataUseAscriber>(); | 549 base::MakeUnique<data_use_measurement::ChromeDataUseAscriber>(); |
550 | 550 |
551 globals_->data_use_aggregator.reset(new data_usage::DataUseAggregator( | 551 globals_->data_use_aggregator.reset(new data_usage::DataUseAggregator( |
552 std::unique_ptr<data_usage::DataUseAnnotator>( | 552 std::unique_ptr<data_usage::DataUseAnnotator>( |
553 new chrome_browser_data_usage::TabIdAnnotator()), | 553 new chrome_browser_data_usage::TabIdAnnotator()), |
554 std::move(data_use_amortizer))); | 554 std::move(data_use_amortizer))); |
555 | 555 |
556 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( | |
557 new ChromeNetworkDelegate(extension_event_router_forwarder(), | |
558 &system_enable_referrers_)); | |
559 // By default, data usage is considered off the record. | |
560 chrome_network_delegate->set_data_use_aggregator( | |
561 globals_->data_use_aggregator.get(), | |
562 true /* is_data_usage_off_the_record */); | |
563 | |
564 #if defined(OS_ANDROID) | 556 #if defined(OS_ANDROID) |
565 globals_->external_data_use_observer.reset( | 557 globals_->external_data_use_observer.reset( |
566 new chrome::android::ExternalDataUseObserver( | 558 new chrome::android::ExternalDataUseObserver( |
567 globals_->data_use_aggregator.get(), | 559 globals_->data_use_aggregator.get(), |
568 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 560 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
569 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI))); | 561 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI))); |
570 #endif // defined(OS_ANDROID) | 562 #endif // defined(OS_ANDROID) |
571 | 563 |
572 globals_->system_network_delegate = | |
573 globals_->data_use_ascriber->CreateNetworkDelegate( | |
574 std::move(chrome_network_delegate), GetMetricsDataUseForwarder()); | |
575 | |
576 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 564 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
577 | 565 |
578 std::map<std::string, std::string> network_quality_estimator_params; | 566 std::map<std::string, std::string> network_quality_estimator_params; |
579 variations::GetVariationParams(kNetworkQualityEstimatorFieldTrialName, | 567 variations::GetVariationParams(kNetworkQualityEstimatorFieldTrialName, |
580 &network_quality_estimator_params); | 568 &network_quality_estimator_params); |
581 | 569 |
582 if (command_line.HasSwitch(switches::kForceEffectiveConnectionType)) { | 570 if (command_line.HasSwitch(switches::kForceEffectiveConnectionType)) { |
583 const std::string force_ect_value = | 571 const std::string force_ect_value = |
584 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 572 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
585 switches::kForceEffectiveConnectionType); | 573 switches::kForceEffectiveConnectionType); |
(...skipping 25 matching lines...) Expand all Loading... |
611 base::MakeUnique<net::MultiThreadedCertVerifier>( | 599 base::MakeUnique<net::MultiThreadedCertVerifier>( |
612 new chromeos::CertVerifyProcChromeOS())); | 600 new chromeos::CertVerifyProcChromeOS())); |
613 #else | 601 #else |
614 globals_->cert_verifier = IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( | 602 globals_->cert_verifier = IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( |
615 command_line, net::CertVerifier::CreateDefault()); | 603 command_line, net::CertVerifier::CreateDefault()); |
616 UMA_HISTOGRAM_BOOLEAN( | 604 UMA_HISTOGRAM_BOOLEAN( |
617 "Net.Certificate.IgnoreCertificateErrorsSPKIListPresent", | 605 "Net.Certificate.IgnoreCertificateErrorsSPKIListPresent", |
618 command_line.HasSwitch(switches::kIgnoreCertificateErrorsSPKIList)); | 606 command_line.HasSwitch(switches::kIgnoreCertificateErrorsSPKIList)); |
619 #endif | 607 #endif |
620 | 608 |
621 globals_->transport_security_state.reset(new net::TransportSecurityState()); | |
622 | |
623 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( | 609 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( |
624 net::ct::CreateLogVerifiersForKnownLogs()); | 610 net::ct::CreateLogVerifiersForKnownLogs()); |
625 | 611 |
626 globals_->ct_logs.assign(ct_logs.begin(), ct_logs.end()); | 612 globals_->ct_logs.assign(ct_logs.begin(), ct_logs.end()); |
627 | 613 |
628 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 614 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
629 globals_->cert_transparency_verifier.reset(ct_verifier); | 615 globals_->cert_transparency_verifier.reset(ct_verifier); |
630 // Add built-in logs | 616 // Add built-in logs |
631 ct_verifier->AddLogs(globals_->ct_logs); | 617 ct_verifier->AddLogs(globals_->ct_logs); |
632 | 618 |
633 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( | 619 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( |
634 globals_->ct_logs, net_log_)); | 620 globals_->ct_logs, net_log_)); |
635 // Register the ct_tree_tracker_ as observer for new STHs. | 621 // Register the ct_tree_tracker_ as observer for new STHs. |
636 RegisterSTHObserver(ct_tree_tracker_.get()); | 622 RegisterSTHObserver(ct_tree_tracker_.get()); |
637 // Register the ct_tree_tracker_ as observer for verified SCTs. | 623 // Register the ct_tree_tracker_ as observer for verified SCTs. |
638 globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get()); | 624 globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get()); |
639 | 625 |
640 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer()); | |
641 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get(); | |
642 | |
643 globals_->ssl_config_service = GetSSLConfigService(); | |
644 | |
645 CreateDefaultAuthHandlerFactory(); | 626 CreateDefaultAuthHandlerFactory(); |
646 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | |
647 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); | 627 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); |
648 globals_->host_mapping_rules.reset(new net::HostMappingRules()); | 628 globals_->host_mapping_rules.reset(new net::HostMappingRules()); |
649 if (command_line.HasSwitch(switches::kHostRules)) { | 629 if (command_line.HasSwitch(switches::kHostRules)) { |
650 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); | 630 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
651 globals_->host_mapping_rules->SetRulesFromString( | 631 globals_->host_mapping_rules->SetRulesFromString( |
652 command_line.GetSwitchValueASCII(switches::kHostRules)); | 632 command_line.GetSwitchValueASCII(switches::kHostRules)); |
653 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); | 633 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
654 } | 634 } |
655 params_.host_mapping_rules = *globals_->host_mapping_rules.get(); | 635 params_.host_mapping_rules = *globals_->host_mapping_rules.get(); |
656 globals_->http_user_agent_settings.reset( | |
657 new net::StaticHttpUserAgentSettings(std::string(), GetUserAgent())); | |
658 globals_->enable_brotli = | 636 globals_->enable_brotli = |
659 base::FeatureList::IsEnabled(features::kBrotliEncoding); | 637 base::FeatureList::IsEnabled(features::kBrotliEncoding); |
660 params_.enable_token_binding = | 638 params_.enable_token_binding = |
661 base::FeatureList::IsEnabled(features::kTokenBinding); | 639 base::FeatureList::IsEnabled(features::kTokenBinding); |
662 | 640 |
663 // Check for OS support of TCP FastOpen, and turn it on for all connections if | 641 // Check for OS support of TCP FastOpen, and turn it on for all connections if |
664 // indicated by user. | 642 // indicated by user. |
665 // TODO(rch): Make the client socket factory a per-network session instance, | 643 // TODO(rch): Make the client socket factory a per-network session instance, |
666 // constructed from a NetworkSession::Params, to allow us to move this option | 644 // constructed from a NetworkSession::Params, to allow us to move this option |
667 // to IOThread::Globals & HttpNetworkSession::Params. | 645 // to IOThread::Globals & HttpNetworkSession::Params. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 globals_->system_request_context_storage = | 845 globals_->system_request_context_storage = |
868 base::MakeUnique<net::URLRequestContextStorage>(context); | 846 base::MakeUnique<net::URLRequestContextStorage>(context); |
869 net::URLRequestContextStorage* context_storage = | 847 net::URLRequestContextStorage* context_storage = |
870 globals_->system_request_context_storage.get(); | 848 globals_->system_request_context_storage.get(); |
871 | 849 |
872 context->set_network_quality_estimator( | 850 context->set_network_quality_estimator( |
873 globals_->network_quality_estimator.get()); | 851 globals_->network_quality_estimator.get()); |
874 context->set_enable_brotli(globals_->enable_brotli); | 852 context->set_enable_brotli(globals_->enable_brotli); |
875 context->set_name("system"); | 853 context->set_name("system"); |
876 | 854 |
877 context->set_http_user_agent_settings( | 855 context_storage->set_http_user_agent_settings( |
878 globals_->http_user_agent_settings.get()); | 856 base::MakeUnique<net::StaticHttpUserAgentSettings>(std::string(), |
879 context->set_network_delegate(globals_->system_network_delegate.get()); | 857 GetUserAgent())); |
| 858 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
| 859 new ChromeNetworkDelegate(extension_event_router_forwarder(), |
| 860 &system_enable_referrers_)); |
| 861 // By default, data usage is considered off the record. |
| 862 chrome_network_delegate->set_data_use_aggregator( |
| 863 globals_->data_use_aggregator.get(), |
| 864 true /* is_data_usage_off_the_record */); |
| 865 context_storage->set_network_delegate( |
| 866 globals_->data_use_ascriber->CreateNetworkDelegate( |
| 867 std::move(chrome_network_delegate), GetMetricsDataUseForwarder())); |
880 context->set_net_log(net_log_); | 868 context->set_net_log(net_log_); |
881 context->set_host_resolver(globals_->host_resolver.get()); | 869 context->set_host_resolver(globals_->host_resolver.get()); |
882 | 870 |
883 context->set_ssl_config_service(globals_->ssl_config_service.get()); | 871 context_storage->set_ssl_config_service(GetSSLConfigService()); |
884 context->set_http_auth_handler_factory( | 872 context->set_http_auth_handler_factory( |
885 globals_->http_auth_handler_factory.get()); | 873 globals_->http_auth_handler_factory.get()); |
886 | 874 |
887 // In-memory cookie store. | 875 // In-memory cookie store. |
888 context_storage->set_cookie_store( | 876 context_storage->set_cookie_store( |
889 content::CreateCookieStore(content::CookieStoreConfig())); | 877 content::CreateCookieStore(content::CookieStoreConfig())); |
890 // In-memory channel ID store. | 878 // In-memory channel ID store. |
891 context_storage->set_channel_id_service( | 879 context_storage->set_channel_id_service( |
892 base::MakeUnique<net::ChannelIDService>( | 880 base::MakeUnique<net::ChannelIDService>( |
893 new net::DefaultChannelIDStore(nullptr))); | 881 new net::DefaultChannelIDStore(nullptr))); |
894 context->cookie_store()->SetChannelIDServiceID( | 882 context->cookie_store()->SetChannelIDServiceID( |
895 context->channel_id_service()->GetUniqueID()); | 883 context->channel_id_service()->GetUniqueID()); |
896 | 884 |
897 context->set_transport_security_state( | 885 context_storage->set_transport_security_state( |
898 globals_->transport_security_state.get()); | 886 base::MakeUnique<net::TransportSecurityState>()); |
899 | 887 |
900 context->set_http_server_properties(globals_->http_server_properties.get()); | 888 context_storage->set_http_server_properties( |
| 889 base::MakeUnique<net::HttpServerPropertiesImpl>()); |
901 | 890 |
902 context->set_cert_verifier(globals_->cert_verifier.get()); | 891 context->set_cert_verifier(globals_->cert_verifier.get()); |
903 context->set_cert_transparency_verifier( | 892 context->set_cert_transparency_verifier( |
904 globals_->cert_transparency_verifier.get()); | 893 globals_->cert_transparency_verifier.get()); |
905 context->set_ct_policy_enforcer(globals_->ct_policy_enforcer.get()); | 894 context_storage->set_ct_policy_enforcer( |
| 895 base::MakeUnique<net::CTPolicyEnforcer>()); |
906 | 896 |
907 const base::CommandLine& command_line = | 897 const base::CommandLine& command_line = |
908 *base::CommandLine::ForCurrentProcess(); | 898 *base::CommandLine::ForCurrentProcess(); |
909 context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService( | 899 context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService( |
910 net_log_, context, globals_->system_network_delegate.get(), | 900 net_log_, context, context->network_delegate(), |
911 std::move(system_proxy_config_service_), command_line, | 901 std::move(system_proxy_config_service_), command_line, |
912 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled())); | 902 WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled())); |
913 | 903 |
914 net::HttpNetworkSession::Params system_params(params_); | 904 net::HttpNetworkSession::Params system_params(params_); |
915 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( | 905 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( |
916 context, &system_params); | 906 context, &system_params); |
917 | 907 |
918 context_storage->set_http_network_session( | 908 context_storage->set_http_network_session( |
919 base::MakeUnique<net::HttpNetworkSession>(system_params)); | 909 base::MakeUnique<net::HttpNetworkSession>(system_params)); |
920 context_storage->set_http_transaction_factory( | 910 context_storage->set_http_transaction_factory( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 1021 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
1032 } | 1022 } |
1033 | 1023 |
1034 params->http_09_on_non_default_ports_enabled = | 1024 params->http_09_on_non_default_ports_enabled = |
1035 http_09_on_non_default_ports_enabled; | 1025 http_09_on_non_default_ports_enabled; |
1036 } | 1026 } |
1037 | 1027 |
1038 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { | 1028 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { |
1039 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); | 1029 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); |
1040 } | 1030 } |
OLD | NEW |