| 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 22 matching lines...) Expand all Loading... |
| 33 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 34 #include "base/trace_event/trace_event.h" | 34 #include "base/trace_event/trace_event.h" |
| 35 #include "build/build_config.h" | 35 #include "build/build_config.h" |
| 36 #include "chrome/browser/browser_process.h" | 36 #include "chrome/browser/browser_process.h" |
| 37 #include "chrome/browser/data_usage/tab_id_annotator.h" | 37 #include "chrome/browser/data_usage/tab_id_annotator.h" |
| 38 #include "chrome/browser/net/async_dns_field_trial.h" | 38 #include "chrome/browser/net/async_dns_field_trial.h" |
| 39 #include "chrome/browser/net/chrome_network_delegate.h" | 39 #include "chrome/browser/net/chrome_network_delegate.h" |
| 40 #include "chrome/browser/net/connect_interceptor.h" | 40 #include "chrome/browser/net/connect_interceptor.h" |
| 41 #include "chrome/browser/net/dns_probe_service.h" | 41 #include "chrome/browser/net/dns_probe_service.h" |
| 42 #include "chrome/browser/net/proxy_service_factory.h" | 42 #include "chrome/browser/net/proxy_service_factory.h" |
| 43 #include "chrome/browser/net/sth_distributor_provider.h" |
| 43 #include "chrome/common/channel_info.h" | 44 #include "chrome/common/channel_info.h" |
| 44 #include "chrome/common/chrome_content_client.h" | 45 #include "chrome/common/chrome_content_client.h" |
| 45 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 46 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 48 #include "components/certificate_transparency/tree_state_tracker.h" |
| 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 48 #include "components/data_usage/core/data_use_aggregator.h" | 50 #include "components/data_usage/core/data_use_aggregator.h" |
| 49 #include "components/data_usage/core/data_use_amortizer.h" | 51 #include "components/data_usage/core/data_use_amortizer.h" |
| 50 #include "components/data_usage/core/data_use_annotator.h" | 52 #include "components/data_usage/core/data_use_annotator.h" |
| 51 #include "components/metrics/metrics_service.h" | 53 #include "components/metrics/metrics_service.h" |
| 52 #include "components/net_log/chrome_net_log.h" | 54 #include "components/net_log/chrome_net_log.h" |
| 53 #include "components/policy/core/common/policy_service.h" | 55 #include "components/policy/core/common/policy_service.h" |
| 54 #include "components/prefs/pref_registry_simple.h" | 56 #include "components/prefs/pref_registry_simple.h" |
| 55 #include "components/prefs/pref_service.h" | 57 #include "components/prefs/pref_service.h" |
| 56 #include "components/proxy_config/pref_proxy_config_tracker.h" | 58 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 57 #include "components/variations/variations_associated_data.h" | 59 #include "components/variations/variations_associated_data.h" |
| 58 #include "components/version_info/version_info.h" | 60 #include "components/version_info/version_info.h" |
| 59 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
| 60 #include "content/public/browser/cookie_store_factory.h" | 62 #include "content/public/browser/cookie_store_factory.h" |
| 61 #include "content/public/common/content_features.h" | 63 #include "content/public/common/content_features.h" |
| 62 #include "content/public/common/content_switches.h" | 64 #include "content/public/common/content_switches.h" |
| 63 #include "content/public/common/user_agent.h" | 65 #include "content/public/common/user_agent.h" |
| 64 #include "net/base/host_mapping_rules.h" | 66 #include "net/base/host_mapping_rules.h" |
| 65 #include "net/base/logging_network_change_observer.h" | 67 #include "net/base/logging_network_change_observer.h" |
| 66 #include "net/base/sdch_manager.h" | 68 #include "net/base/sdch_manager.h" |
| 67 #include "net/cert/cert_verifier.h" | 69 #include "net/cert/cert_verifier.h" |
| 68 #include "net/cert/cert_verify_proc.h" | 70 #include "net/cert/cert_verify_proc.h" |
| 69 #include "net/cert/ct_known_logs.h" | 71 #include "net/cert/ct_known_logs.h" |
| 70 #include "net/cert/ct_log_verifier.h" | 72 #include "net/cert/ct_log_verifier.h" |
| 71 #include "net/cert/ct_policy_enforcer.h" | 73 #include "net/cert/ct_policy_enforcer.h" |
| 72 #include "net/cert/ct_verifier.h" | 74 #include "net/cert/ct_verifier.h" |
| 73 #include "net/cert/multi_log_ct_verifier.h" | 75 #include "net/cert/multi_log_ct_verifier.h" |
| 74 #include "net/cert/multi_threaded_cert_verifier.h" | 76 #include "net/cert/multi_threaded_cert_verifier.h" |
| 77 #include "net/cert/sth_distributor.h" |
| 78 #include "net/cert/sth_observer.h" |
| 75 #include "net/cookies/cookie_store.h" | 79 #include "net/cookies/cookie_store.h" |
| 76 #include "net/dns/host_cache.h" | 80 #include "net/dns/host_cache.h" |
| 77 #include "net/dns/host_resolver.h" | 81 #include "net/dns/host_resolver.h" |
| 78 #include "net/dns/mapped_host_resolver.h" | 82 #include "net/dns/mapped_host_resolver.h" |
| 79 #include "net/ftp/ftp_network_layer.h" | 83 #include "net/ftp/ftp_network_layer.h" |
| 80 #include "net/http/http_auth_filter.h" | 84 #include "net/http/http_auth_filter.h" |
| 81 #include "net/http/http_auth_handler_factory.h" | 85 #include "net/http/http_auth_handler_factory.h" |
| 82 #include "net/http/http_auth_preferences.h" | 86 #include "net/http/http_auth_preferences.h" |
| 83 #include "net/http/http_network_layer.h" | 87 #include "net/http/http_network_layer.h" |
| 84 #include "net/http/http_server_properties_impl.h" | 88 #include "net/http/http_server_properties_impl.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 value->GetAsBoolean(&is_quic_allowed_by_policy_); | 459 value->GetAsBoolean(&is_quic_allowed_by_policy_); |
| 456 | 460 |
| 457 // Some unit tests use IOThread but do not initialize MetricsService. In that | 461 // Some unit tests use IOThread but do not initialize MetricsService. In that |
| 458 // case it is fine not to have |metrics_data_use_forwarder_|. | 462 // case it is fine not to have |metrics_data_use_forwarder_|. |
| 459 if (g_browser_process->metrics_service()) { | 463 if (g_browser_process->metrics_service()) { |
| 460 // Callback for updating data use prefs should be obtained on UI thread. | 464 // Callback for updating data use prefs should be obtained on UI thread. |
| 461 metrics_data_use_forwarder_ = | 465 metrics_data_use_forwarder_ = |
| 462 g_browser_process->metrics_service()->GetDataUseForwardingCallback(); | 466 g_browser_process->metrics_service()->GetDataUseForwardingCallback(); |
| 463 } | 467 } |
| 464 | 468 |
| 469 chrome_browser_net::SetGlobalSTHDistributor( |
| 470 std::unique_ptr<net::ct::STHDistributor>(new net::ct::STHDistributor())); |
| 471 |
| 465 BrowserThread::SetDelegate(BrowserThread::IO, this); | 472 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 466 } | 473 } |
| 467 | 474 |
| 468 IOThread::~IOThread() { | 475 IOThread::~IOThread() { |
| 469 // This isn't needed for production code, but in tests, IOThread may | 476 // This isn't needed for production code, but in tests, IOThread may |
| 470 // be multiply constructed. | 477 // be multiply constructed. |
| 471 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 478 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
| 472 | 479 |
| 473 pref_proxy_config_tracker_->DetachFromPrefService(); | 480 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 474 DCHECK(!globals_); | 481 DCHECK(!globals_); |
| 482 |
| 483 // Destroy the old distributor to check that the observers list it holds is |
| 484 // empty. |
| 485 chrome_browser_net::SetGlobalSTHDistributor(nullptr); |
| 475 } | 486 } |
| 476 | 487 |
| 477 IOThread::Globals* IOThread::globals() { | 488 IOThread::Globals* IOThread::globals() { |
| 478 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 489 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 479 return globals_; | 490 return globals_; |
| 480 } | 491 } |
| 481 | 492 |
| 482 void IOThread::SetGlobalsForTesting(Globals* globals) { | 493 void IOThread::SetGlobalsForTesting(Globals* globals) { |
| 483 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 494 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 484 DCHECK(!globals || !globals_); | 495 DCHECK(!globals || !globals_); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 680 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 670 // is fixed. | 681 // is fixed. |
| 671 tracked_objects::ScopedTracker tracking_profile7( | 682 tracked_objects::ScopedTracker tracking_profile7( |
| 672 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 683 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 673 "466432 IOThread::InitAsync::CreateMultiLogVerifier")); | 684 "466432 IOThread::InitAsync::CreateMultiLogVerifier")); |
| 674 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 685 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
| 675 globals_->cert_transparency_verifier.reset(ct_verifier); | 686 globals_->cert_transparency_verifier.reset(ct_verifier); |
| 676 // Add built-in logs | 687 // Add built-in logs |
| 677 ct_verifier->AddLogs(globals_->ct_logs); | 688 ct_verifier->AddLogs(globals_->ct_logs); |
| 678 | 689 |
| 690 ct_tree_tracker_.reset( |
| 691 new certificate_transparency::TreeStateTracker(globals_->ct_logs)); |
| 692 // Register the ct_tree_tracker_ as observer for new STHs. |
| 693 RegisterSTHObserver(ct_tree_tracker_.get()); |
| 694 // Register the ct_tree_tracker_ as observer for verified SCTs. |
| 695 globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get()); |
| 696 |
| 679 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 697 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 680 // is fixed. | 698 // is fixed. |
| 681 tracked_objects::ScopedTracker tracking_profile10( | 699 tracked_objects::ScopedTracker tracking_profile10( |
| 682 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 700 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 683 "466432 IOThread::InitAsync::CTPolicyEnforcer")); | 701 "466432 IOThread::InitAsync::CTPolicyEnforcer")); |
| 684 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer()); | 702 globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer()); |
| 685 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get(); | 703 params_.ct_policy_enforcer = globals_->ct_policy_enforcer.get(); |
| 686 | 704 |
| 687 globals_->ssl_config_service = GetSSLConfigService(); | 705 globals_->ssl_config_service = GetSSLConfigService(); |
| 688 | 706 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 837 |
| 820 void IOThread::CleanUp() { | 838 void IOThread::CleanUp() { |
| 821 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); | 839 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); |
| 822 | 840 |
| 823 #if defined(USE_NSS_CERTS) | 841 #if defined(USE_NSS_CERTS) |
| 824 net::ShutdownNSSHttpIO(); | 842 net::ShutdownNSSHttpIO(); |
| 825 #endif | 843 #endif |
| 826 | 844 |
| 827 system_url_request_context_getter_ = NULL; | 845 system_url_request_context_getter_ = NULL; |
| 828 | 846 |
| 847 // Unlink the ct_tree_tracker_ from the global cert_transparency_verifier |
| 848 // and unregister it from new STH notifications so it will take no actions |
| 849 // on anything observed during CleanUp process. |
| 850 globals()->cert_transparency_verifier->SetObserver(nullptr); |
| 851 UnregisterSTHObserver(ct_tree_tracker_.get()); |
| 852 |
| 853 ct_tree_tracker_.reset(); |
| 854 |
| 829 // Release objects that the net::URLRequestContext could have been pointing | 855 // Release objects that the net::URLRequestContext could have been pointing |
| 830 // to. | 856 // to. |
| 831 | 857 |
| 832 // Shutdown the HistogramWatcher on the IO thread. | 858 // Shutdown the HistogramWatcher on the IO thread. |
| 833 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 859 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 834 | 860 |
| 835 // This must be reset before the ChromeNetLog is destroyed. | 861 // This must be reset before the ChromeNetLog is destroyed. |
| 836 network_change_observer_.reset(); | 862 network_change_observer_.reset(); |
| 837 | 863 |
| 838 system_proxy_config_service_.reset(); | 864 system_proxy_config_service_.reset(); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 const base::CommandLine& command_line) { | 1334 const base::CommandLine& command_line) { |
| 1309 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) | 1335 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) |
| 1310 return false; | 1336 return false; |
| 1311 | 1337 |
| 1312 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) | 1338 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) |
| 1313 return true; | 1339 return true; |
| 1314 | 1340 |
| 1315 return false; // Default to disabling port selection on all channels. | 1341 return false; // Default to disabling port selection on all channels. |
| 1316 } | 1342 } |
| 1317 | 1343 |
| 1344 void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) { |
| 1345 chrome_browser_net::GetGlobalSTHDistributor()->RegisterObserver(observer); |
| 1346 } |
| 1347 |
| 1348 void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) { |
| 1349 chrome_browser_net::GetGlobalSTHDistributor()->UnregisterObserver(observer); |
| 1350 } |
| 1351 |
| 1318 // static | 1352 // static |
| 1319 net::QuicTagVector | 1353 net::QuicTagVector |
| 1320 IOThread::NetworkSessionConfigurator::GetQuicConnectionOptions( | 1354 IOThread::NetworkSessionConfigurator::GetQuicConnectionOptions( |
| 1321 const base::CommandLine& command_line, | 1355 const base::CommandLine& command_line, |
| 1322 const VariationParameters& quic_trial_params) { | 1356 const VariationParameters& quic_trial_params) { |
| 1323 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { | 1357 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { |
| 1324 return net::QuicUtils::ParseQuicConnectionOptions( | 1358 return net::QuicUtils::ParseQuicConnectionOptions( |
| 1325 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); | 1359 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); |
| 1326 } | 1360 } |
| 1327 | 1361 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1741 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1708 // system URLRequestContext too. There's no reason this should be tied to a | 1742 // system URLRequestContext too. There's no reason this should be tied to a |
| 1709 // profile. | 1743 // profile. |
| 1710 return context; | 1744 return context; |
| 1711 } | 1745 } |
| 1712 | 1746 |
| 1713 const metrics::UpdateUsagePrefCallbackType& | 1747 const metrics::UpdateUsagePrefCallbackType& |
| 1714 IOThread::GetMetricsDataUseForwarder() { | 1748 IOThread::GetMetricsDataUseForwarder() { |
| 1715 return metrics_data_use_forwarder_; | 1749 return metrics_data_use_forwarder_; |
| 1716 } | 1750 } |
| OLD | NEW |