Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "chrome/browser/data_usage/tab_id_annotator.h" | 36 #include "chrome/browser/data_usage/tab_id_annotator.h" |
| 37 #include "chrome/browser/net/async_dns_field_trial.h" | 37 #include "chrome/browser/net/async_dns_field_trial.h" |
| 38 #include "chrome/browser/net/chrome_network_delegate.h" | 38 #include "chrome/browser/net/chrome_network_delegate.h" |
| 39 #include "chrome/browser/net/connect_interceptor.h" | 39 #include "chrome/browser/net/connect_interceptor.h" |
| 40 #include "chrome/browser/net/dns_probe_service.h" | 40 #include "chrome/browser/net/dns_probe_service.h" |
| 41 #include "chrome/browser/net/proxy_service_factory.h" | 41 #include "chrome/browser/net/proxy_service_factory.h" |
| 42 #include "chrome/common/channel_info.h" | 42 #include "chrome/common/channel_info.h" |
| 43 #include "chrome/common/chrome_content_client.h" | 43 #include "chrome/common/chrome_content_client.h" |
| 44 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 46 #include "components/certificate_transparency/tree_state_tracker.h" | |
| 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" | 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" |
| 47 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 48 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
| 48 #include "components/data_usage/core/data_use_aggregator.h" | 49 #include "components/data_usage/core/data_use_aggregator.h" |
| 49 #include "components/data_usage/core/data_use_amortizer.h" | 50 #include "components/data_usage/core/data_use_amortizer.h" |
| 50 #include "components/data_usage/core/data_use_annotator.h" | 51 #include "components/data_usage/core/data_use_annotator.h" |
| 51 #include "components/metrics/metrics_service.h" | 52 #include "components/metrics/metrics_service.h" |
| 52 #include "components/net_log/chrome_net_log.h" | 53 #include "components/net_log/chrome_net_log.h" |
| 53 #include "components/policy/core/common/policy_service.h" | 54 #include "components/policy/core/common/policy_service.h" |
| 54 #include "components/prefs/pref_registry_simple.h" | 55 #include "components/prefs/pref_registry_simple.h" |
| 55 #include "components/prefs/pref_service.h" | 56 #include "components/prefs/pref_service.h" |
| 56 #include "components/proxy_config/pref_proxy_config_tracker.h" | 57 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 57 #include "components/variations/variations_associated_data.h" | 58 #include "components/variations/variations_associated_data.h" |
| 58 #include "components/version_info/version_info.h" | 59 #include "components/version_info/version_info.h" |
| 59 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
| 60 #include "content/public/browser/cookie_store_factory.h" | 61 #include "content/public/browser/cookie_store_factory.h" |
| 61 #include "content/public/common/content_features.h" | 62 #include "content/public/common/content_features.h" |
| 62 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
| 63 #include "content/public/common/user_agent.h" | 64 #include "content/public/common/user_agent.h" |
| 64 #include "net/base/external_estimate_provider.h" | 65 #include "net/base/external_estimate_provider.h" |
| 65 #include "net/base/host_mapping_rules.h" | 66 #include "net/base/host_mapping_rules.h" |
| 66 #include "net/base/network_quality_estimator.h" | 67 #include "net/base/network_quality_estimator.h" |
| 67 #include "net/base/sdch_manager.h" | 68 #include "net/base/sdch_manager.h" |
| 68 #include "net/cert/cert_verifier.h" | 69 #include "net/cert/cert_verifier.h" |
| 69 #include "net/cert/cert_verify_proc.h" | 70 #include "net/cert/cert_verify_proc.h" |
| 70 #include "net/cert/ct_known_logs.h" | 71 #include "net/cert/ct_known_logs.h" |
| 71 #include "net/cert/ct_log_verifier.h" | 72 #include "net/cert/ct_log_verifier.h" |
| 73 #include "net/cert/ct_observer.h" | |
| 72 #include "net/cert/ct_policy_enforcer.h" | 74 #include "net/cert/ct_policy_enforcer.h" |
| 73 #include "net/cert/ct_verifier.h" | 75 #include "net/cert/ct_verifier.h" |
| 74 #include "net/cert/multi_log_ct_verifier.h" | 76 #include "net/cert/multi_log_ct_verifier.h" |
| 75 #include "net/cert/multi_threaded_cert_verifier.h" | 77 #include "net/cert/multi_threaded_cert_verifier.h" |
| 78 #include "net/cert/sth_observer.h" | |
| 79 #include "net/cert/sth_reporter.h" | |
| 76 #include "net/cookies/cookie_store.h" | 80 #include "net/cookies/cookie_store.h" |
| 77 #include "net/dns/host_cache.h" | 81 #include "net/dns/host_cache.h" |
| 78 #include "net/dns/host_resolver.h" | 82 #include "net/dns/host_resolver.h" |
| 79 #include "net/dns/mapped_host_resolver.h" | 83 #include "net/dns/mapped_host_resolver.h" |
| 80 #include "net/ftp/ftp_network_layer.h" | 84 #include "net/ftp/ftp_network_layer.h" |
| 81 #include "net/http/http_auth_filter.h" | 85 #include "net/http/http_auth_filter.h" |
| 82 #include "net/http/http_auth_handler_factory.h" | 86 #include "net/http/http_auth_handler_factory.h" |
| 83 #include "net/http/http_auth_preferences.h" | 87 #include "net/http/http_auth_preferences.h" |
| 84 #include "net/http/http_network_layer.h" | 88 #include "net/http/http_network_layer.h" |
| 85 #include "net/http/http_server_properties_impl.h" | 89 #include "net/http/http_server_properties_impl.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 policy::PolicyService* policy_service, | 427 policy::PolicyService* policy_service, |
| 424 net_log::ChromeNetLog* net_log, | 428 net_log::ChromeNetLog* net_log, |
| 425 extensions::EventRouterForwarder* extension_event_router_forwarder) | 429 extensions::EventRouterForwarder* extension_event_router_forwarder) |
| 426 : net_log_(net_log), | 430 : net_log_(net_log), |
| 427 #if defined(ENABLE_EXTENSIONS) | 431 #if defined(ENABLE_EXTENSIONS) |
| 428 extension_event_router_forwarder_(extension_event_router_forwarder), | 432 extension_event_router_forwarder_(extension_event_router_forwarder), |
| 429 #endif | 433 #endif |
| 430 globals_(NULL), | 434 globals_(NULL), |
| 431 is_spdy_allowed_by_policy_(true), | 435 is_spdy_allowed_by_policy_(true), |
| 432 is_quic_allowed_by_policy_(true), | 436 is_quic_allowed_by_policy_(true), |
| 437 sth_reporter_(nullptr), | |
| 433 creation_time_(base::TimeTicks::Now()), | 438 creation_time_(base::TimeTicks::Now()), |
| 434 weak_factory_(this) { | 439 weak_factory_(this) { |
| 435 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = | 440 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = |
| 436 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 441 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 437 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 442 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 438 negotiate_disable_cname_lookup_.Init( | 443 negotiate_disable_cname_lookup_.Init( |
| 439 prefs::kDisableAuthNegotiateCnameLookup, local_state, | 444 prefs::kDisableAuthNegotiateCnameLookup, local_state, |
| 440 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, | 445 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, |
| 441 base::Unretained(this))); | 446 base::Unretained(this))); |
| 442 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); | 447 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 | 520 |
| 516 BrowserThread::SetDelegate(BrowserThread::IO, this); | 521 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 517 } | 522 } |
| 518 | 523 |
| 519 IOThread::~IOThread() { | 524 IOThread::~IOThread() { |
| 520 // This isn't needed for production code, but in tests, IOThread may | 525 // This isn't needed for production code, but in tests, IOThread may |
| 521 // be multiply constructed. | 526 // be multiply constructed. |
| 522 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 527 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
| 523 | 528 |
| 524 pref_proxy_config_tracker_->DetachFromPrefService(); | 529 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 530 DCHECK(sth_observers_.empty()); | |
| 525 DCHECK(!globals_); | 531 DCHECK(!globals_); |
| 526 } | 532 } |
| 527 | 533 |
| 528 IOThread::Globals* IOThread::globals() { | 534 IOThread::Globals* IOThread::globals() { |
| 529 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 535 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 530 return globals_; | 536 return globals_; |
| 531 } | 537 } |
| 532 | 538 |
| 533 void IOThread::SetGlobalsForTesting(Globals* globals) { | 539 void IOThread::SetGlobalsForTesting(Globals* globals) { |
| 534 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 540 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 | 869 |
| 864 void IOThread::CleanUp() { | 870 void IOThread::CleanUp() { |
| 865 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); | 871 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); |
| 866 | 872 |
| 867 #if defined(USE_NSS_CERTS) | 873 #if defined(USE_NSS_CERTS) |
| 868 net::ShutdownNSSHttpIO(); | 874 net::ShutdownNSSHttpIO(); |
| 869 #endif | 875 #endif |
| 870 | 876 |
| 871 system_url_request_context_getter_ = NULL; | 877 system_url_request_context_getter_ = NULL; |
| 872 | 878 |
| 873 // Release objects that the net::URLRequestContext could have been pointing | 879 // Since the cert_transparency_observer will be deleted first, unlink |
| 874 // to. | 880 // it from the cert_transparency_verifier by nullifying the observer. |
| 881 globals()->cert_transparency_verifier->SetObserver(nullptr); | |
| 882 | |
| 883 if (sth_reporter_) { | |
| 884 for (const auto& observer : sth_observers_) { | |
| 885 sth_reporter_->UnregisterObserver(observer); | |
| 886 } | |
| 887 // Make sure no registration happens after CleanUp | |
| 888 sth_reporter_ = nullptr; | |
| 889 } | |
| 890 sth_observers_.clear(); | |
| 875 | 891 |
| 876 // Shutdown the HistogramWatcher on the IO thread. | 892 // Shutdown the HistogramWatcher on the IO thread. |
| 877 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 893 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 878 | 894 |
| 879 // This must be reset before the ChromeNetLog is destroyed. | 895 // This must be reset before the ChromeNetLog is destroyed. |
| 880 network_change_observer_.reset(); | 896 network_change_observer_.reset(); |
| 881 | 897 |
| 882 system_proxy_config_service_.reset(); | 898 system_proxy_config_service_.reset(); |
| 883 delete globals_; | 899 delete globals_; |
| 884 globals_ = NULL; | 900 globals_ = NULL; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 const base::CommandLine& command_line = | 1224 const base::CommandLine& command_line = |
| 1209 *base::CommandLine::ForCurrentProcess(); | 1225 *base::CommandLine::ForCurrentProcess(); |
| 1210 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService( | 1226 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService( |
| 1211 net_log_, globals_->proxy_script_fetcher_context.get(), | 1227 net_log_, globals_->proxy_script_fetcher_context.get(), |
| 1212 globals_->system_network_delegate.get(), | 1228 globals_->system_network_delegate.get(), |
| 1213 std::move(system_proxy_config_service_), command_line, | 1229 std::move(system_proxy_config_service_), command_line, |
| 1214 quick_check_enabled_.GetValue()); | 1230 quick_check_enabled_.GetValue()); |
| 1215 | 1231 |
| 1216 globals_->system_request_context.reset( | 1232 globals_->system_request_context.reset( |
| 1217 ConstructSystemRequestContext(globals_, params_, net_log_)); | 1233 ConstructSystemRequestContext(globals_, params_, net_log_)); |
| 1234 | |
| 1235 globals_->cert_transparency_observer.reset( | |
| 1236 new certificate_transparency::TreeStateTracker(globals_->ct_logs)); | |
| 1237 RegisterSTHObserver(globals_->cert_transparency_observer.get()); | |
| 1238 // The |cert_transparency_verifier| is the same one held by | |
| 1239 // the |proxy_script_fetcher_context| and |system_request_context|, | |
| 1240 // so no need to set the observer in their cert_transparency_verifiers. | |
| 1241 globals_->cert_transparency_verifier->SetObserver( | |
| 1242 globals_->cert_transparency_observer.get()); | |
| 1218 } | 1243 } |
| 1219 | 1244 |
| 1220 void IOThread::UpdateDnsClientEnabled() { | 1245 void IOThread::UpdateDnsClientEnabled() { |
| 1221 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); | 1246 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
| 1222 } | 1247 } |
| 1223 | 1248 |
| 1224 // static | 1249 // static |
| 1225 void IOThread::NetworkSessionConfigurator::ConfigureQuicParams( | 1250 void IOThread::NetworkSessionConfigurator::ConfigureQuicParams( |
| 1226 const base::CommandLine& command_line, | 1251 const base::CommandLine& command_line, |
| 1227 base::StringPiece quic_trial_group, | 1252 base::StringPiece quic_trial_group, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1381 const base::CommandLine& command_line) { | 1406 const base::CommandLine& command_line) { |
| 1382 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) | 1407 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) |
| 1383 return false; | 1408 return false; |
| 1384 | 1409 |
| 1385 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) | 1410 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) |
| 1386 return true; | 1411 return true; |
| 1387 | 1412 |
| 1388 return false; // Default to disabling port selection on all channels. | 1413 return false; // Default to disabling port selection on all channels. |
| 1389 } | 1414 } |
| 1390 | 1415 |
| 1416 void IOThread::RegisterSTHReporter(net::ct::STHReporter* reporter) { | |
| 1417 DCHECK(globals()); | |
| 1418 // A sanity check to make sure the observer was created by now. | |
| 1419 DCHECK(globals()->cert_transparency_observer.get()); | |
|
Ryan Sleevi
2016/04/27 23:05:59
Why? The justification for why this is done is unc
Eran Messeri
2016/05/03 15:00:12
Removed, this was to verify assumptions during dev
| |
| 1420 | |
| 1421 sth_reporter_ = reporter; | |
| 1422 // Register all observers that were created before the reporter was. | |
| 1423 for (const auto& observer : sth_observers_) { | |
| 1424 sth_reporter_->RegisterObserver(observer); | |
| 1425 } | |
| 1426 } | |
| 1427 | |
| 1428 void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) { | |
| 1429 sth_observers_.insert(observer); | |
| 1430 // If a reporter was set, also register this observer with it. | |
| 1431 // Otherwise it will be registered in RegisterSTHReporter with all | |
| 1432 // other pending observers. | |
| 1433 if (sth_reporter_) { | |
|
Ryan Sleevi
2016/04/27 23:05:59
Dominant style in this file seems to be no braces
Eran Messeri
2016/05/03 15:00:12
Done.
(Note this file was removed in the next patc
| |
| 1434 sth_reporter_->RegisterObserver(observer); | |
| 1435 } | |
| 1436 } | |
| 1437 | |
| 1438 void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) { | |
| 1439 DCHECK_NE(sth_observers_.count(observer), 0u); | |
|
Ryan Sleevi
2016/04/27 23:05:59
Why? It's clear that you intend to make sure the o
Eran Messeri
2016/05/03 15:00:12
I'd like to verify that the object was (1) registe
| |
| 1440 sth_observers_.erase(observer); | |
| 1441 if (sth_reporter_) { | |
| 1442 sth_reporter_->UnregisterObserver(observer); | |
| 1443 } | |
| 1444 } | |
|
Ryan Sleevi
2016/04/27 23:05:59
Is this level of reciprocity (set a reporter it re
Eran Messeri
2016/05/03 15:00:12
Good point. I have:
(1) Added a DCHECK to verify t
| |
| 1445 | |
| 1391 // static | 1446 // static |
| 1392 net::QuicTagVector | 1447 net::QuicTagVector |
| 1393 IOThread::NetworkSessionConfigurator::GetQuicConnectionOptions( | 1448 IOThread::NetworkSessionConfigurator::GetQuicConnectionOptions( |
| 1394 const base::CommandLine& command_line, | 1449 const base::CommandLine& command_line, |
| 1395 const VariationParameters& quic_trial_params) { | 1450 const VariationParameters& quic_trial_params) { |
| 1396 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { | 1451 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { |
| 1397 return net::QuicUtils::ParseQuicConnectionOptions( | 1452 return net::QuicUtils::ParseQuicConnectionOptions( |
| 1398 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); | 1453 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); |
| 1399 } | 1454 } |
| 1400 | 1455 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1776 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1831 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1777 // system URLRequestContext too. There's no reason this should be tied to a | 1832 // system URLRequestContext too. There's no reason this should be tied to a |
| 1778 // profile. | 1833 // profile. |
| 1779 return context; | 1834 return context; |
| 1780 } | 1835 } |
| 1781 | 1836 |
| 1782 const metrics::UpdateUsagePrefCallbackType& | 1837 const metrics::UpdateUsagePrefCallbackType& |
| 1783 IOThread::GetMetricsDataUseForwarder() { | 1838 IOThread::GetMetricsDataUseForwarder() { |
| 1784 return metrics_data_use_forwarder_; | 1839 return metrics_data_use_forwarder_; |
| 1785 } | 1840 } |
| OLD | NEW |