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

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

Issue 1845113003: Certificate Transparency: Start tracking logs' state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Getting rid of a redundant class Created 4 years, 8 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/browser/profiles/profile_io_data.h » ('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 24 matching lines...) Expand all
35 #include "chrome/browser/data_usage/tab_id_annotator.h" 35 #include "chrome/browser/data_usage/tab_id_annotator.h"
36 #include "chrome/browser/net/async_dns_field_trial.h" 36 #include "chrome/browser/net/async_dns_field_trial.h"
37 #include "chrome/browser/net/chrome_network_delegate.h" 37 #include "chrome/browser/net/chrome_network_delegate.h"
38 #include "chrome/browser/net/connect_interceptor.h" 38 #include "chrome/browser/net/connect_interceptor.h"
39 #include "chrome/browser/net/dns_probe_service.h" 39 #include "chrome/browser/net/dns_probe_service.h"
40 #include "chrome/browser/net/proxy_service_factory.h" 40 #include "chrome/browser/net/proxy_service_factory.h"
41 #include "chrome/common/channel_info.h" 41 #include "chrome/common/channel_info.h"
42 #include "chrome/common/chrome_content_client.h" 42 #include "chrome/common/chrome_content_client.h"
43 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/pref_names.h" 44 #include "chrome/common/pref_names.h"
45 #include "components/certificate_transparency/tree_state_tracker.h"
45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h"
46 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 47 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
47 #include "components/data_usage/core/data_use_aggregator.h" 48 #include "components/data_usage/core/data_use_aggregator.h"
48 #include "components/data_usage/core/data_use_amortizer.h" 49 #include "components/data_usage/core/data_use_amortizer.h"
49 #include "components/data_usage/core/data_use_annotator.h" 50 #include "components/data_usage/core/data_use_annotator.h"
50 #include "components/net_log/chrome_net_log.h" 51 #include "components/net_log/chrome_net_log.h"
51 #include "components/policy/core/common/policy_service.h" 52 #include "components/policy/core/common/policy_service.h"
52 #include "components/prefs/pref_registry_simple.h" 53 #include "components/prefs/pref_registry_simple.h"
53 #include "components/prefs/pref_service.h" 54 #include "components/prefs/pref_service.h"
54 #include "components/proxy_config/pref_proxy_config_tracker.h" 55 #include "components/proxy_config/pref_proxy_config_tracker.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 policy::PolicyService* policy_service, 429 policy::PolicyService* policy_service,
429 net_log::ChromeNetLog* net_log, 430 net_log::ChromeNetLog* net_log,
430 extensions::EventRouterForwarder* extension_event_router_forwarder) 431 extensions::EventRouterForwarder* extension_event_router_forwarder)
431 : net_log_(net_log), 432 : net_log_(net_log),
432 #if defined(ENABLE_EXTENSIONS) 433 #if defined(ENABLE_EXTENSIONS)
433 extension_event_router_forwarder_(extension_event_router_forwarder), 434 extension_event_router_forwarder_(extension_event_router_forwarder),
434 #endif 435 #endif
435 globals_(NULL), 436 globals_(NULL),
436 is_spdy_disabled_by_policy_(false), 437 is_spdy_disabled_by_policy_(false),
437 is_quic_allowed_by_policy_(true), 438 is_quic_allowed_by_policy_(true),
439 sth_reporter_(nullptr),
438 creation_time_(base::TimeTicks::Now()), 440 creation_time_(base::TimeTicks::Now()),
439 weak_factory_(this) { 441 weak_factory_(this) {
440 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = 442 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy =
441 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 443 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
442 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); 444 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes);
443 negotiate_disable_cname_lookup_.Init( 445 negotiate_disable_cname_lookup_.Init(
444 prefs::kDisableAuthNegotiateCnameLookup, local_state, 446 prefs::kDisableAuthNegotiateCnameLookup, local_state,
445 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, 447 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup,
446 base::Unretained(this))); 448 base::Unretained(this)));
447 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); 449 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 512
511 BrowserThread::SetDelegate(BrowserThread::IO, this); 513 BrowserThread::SetDelegate(BrowserThread::IO, this);
512 } 514 }
513 515
514 IOThread::~IOThread() { 516 IOThread::~IOThread() {
515 // This isn't needed for production code, but in tests, IOThread may 517 // This isn't needed for production code, but in tests, IOThread may
516 // be multiply constructed. 518 // be multiply constructed.
517 BrowserThread::SetDelegate(BrowserThread::IO, NULL); 519 BrowserThread::SetDelegate(BrowserThread::IO, NULL);
518 520
519 pref_proxy_config_tracker_->DetachFromPrefService(); 521 pref_proxy_config_tracker_->DetachFromPrefService();
522 DCHECK(sth_observers_.empty());
520 DCHECK(!globals_); 523 DCHECK(!globals_);
521 } 524 }
522 525
523 IOThread::Globals* IOThread::globals() { 526 IOThread::Globals* IOThread::globals() {
524 DCHECK_CURRENTLY_ON(BrowserThread::IO); 527 DCHECK_CURRENTLY_ON(BrowserThread::IO);
525 return globals_; 528 return globals_;
526 } 529 }
527 530
528 void IOThread::SetGlobalsForTesting(Globals* globals) { 531 void IOThread::SetGlobalsForTesting(Globals* globals) {
529 DCHECK_CURRENTLY_ON(BrowserThread::IO); 532 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); 867 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks();
865 868
866 #if defined(USE_NSS_CERTS) 869 #if defined(USE_NSS_CERTS)
867 net::ShutdownNSSHttpIO(); 870 net::ShutdownNSSHttpIO();
868 #endif 871 #endif
869 872
870 system_url_request_context_getter_ = NULL; 873 system_url_request_context_getter_ = NULL;
871 874
872 // Release objects that the net::URLRequestContext could have been pointing 875 // Release objects that the net::URLRequestContext could have been pointing
873 // to. 876 // to.
877 globals()->cert_transparency_verifier->SetObserver(nullptr);
878
879 VLOG(1) << "XXX: IOThread::CleanUp";
880 if (sth_reporter_) {
881 for (auto observer : sth_observers_) {
882 sth_reporter_->UnregisterObserver(observer);
883 }
884 // Make sure no registration happens after CleanUp
885 sth_reporter_ = nullptr;
886 }
887 sth_observers_.clear();
874 888
875 // Shutdown the HistogramWatcher on the IO thread. 889 // Shutdown the HistogramWatcher on the IO thread.
876 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); 890 net::NetworkChangeNotifier::ShutdownHistogramWatcher();
877 891
878 // This must be reset before the ChromeNetLog is destroyed. 892 // This must be reset before the ChromeNetLog is destroyed.
879 network_change_observer_.reset(); 893 network_change_observer_.reset();
880 894
881 system_proxy_config_service_.reset(); 895 system_proxy_config_service_.reset();
882 delete globals_; 896 delete globals_;
883 globals_ = NULL; 897 globals_ = NULL;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 const base::CommandLine& command_line = 1220 const base::CommandLine& command_line =
1207 *base::CommandLine::ForCurrentProcess(); 1221 *base::CommandLine::ForCurrentProcess();
1208 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService( 1222 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService(
1209 net_log_, globals_->proxy_script_fetcher_context.get(), 1223 net_log_, globals_->proxy_script_fetcher_context.get(),
1210 globals_->system_network_delegate.get(), 1224 globals_->system_network_delegate.get(),
1211 std::move(system_proxy_config_service_), command_line, 1225 std::move(system_proxy_config_service_), command_line,
1212 quick_check_enabled_.GetValue()); 1226 quick_check_enabled_.GetValue());
1213 1227
1214 globals_->system_request_context.reset( 1228 globals_->system_request_context.reset(
1215 ConstructSystemRequestContext(globals_, net_log_)); 1229 ConstructSystemRequestContext(globals_, net_log_));
1230
1231 VLOG(1) << "Creating TreeStateTracker observer on IOThread.";
1232 // TODO(eranm): Clean up the order of pointer creation and
1233 // moving around. This should be a scoped_ptr until ownership
1234 // is transferred to globals_->cert_transparency_observer
1235 certificate_transparency::TreeStateTracker* scts_observer(
1236 new certificate_transparency::TreeStateTracker(globals_->ct_logs));
1237 globals_->cert_transparency_observer.reset(scts_observer);
1238 RegisterSTHObserver(scts_observer);
1239 VLOG(1)
1240 << "XXX IOThread::InitSystemRequestContextOnIOThread, created observer.";
1241 // The |cert_transparency_verifier| is the same one held by
1242 // the |proxy_script_fetcher_context| and |system_request_context|,
1243 // so no need to set the observer in their cert_transparency_verifiers.
1244 globals_->cert_transparency_verifier->SetObserver(scts_observer);
1245 VLOG(1) << "TreeStateTracker observer on IOThread created.";
1216 } 1246 }
1217 1247
1218 void IOThread::UpdateDnsClientEnabled() { 1248 void IOThread::UpdateDnsClientEnabled() {
1219 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 1249 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
1220 } 1250 }
1221 1251
1222 void IOThread::ConfigurePriorityDependencies() { 1252 void IOThread::ConfigurePriorityDependencies() {
1223 std::string group = 1253 std::string group =
1224 base::FieldTrialList::FindFullName(kSpdyDependenciesFieldTrial); 1254 base::FieldTrialList::FindFullName(kSpdyDependenciesFieldTrial);
1225 if (group == kSpdyDependenciesFieldTrialEnable) { 1255 if (group == kSpdyDependenciesFieldTrialEnable) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 const base::CommandLine& command_line) { 1429 const base::CommandLine& command_line) {
1400 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) 1430 if (command_line.HasSwitch(switches::kDisableQuicPortSelection))
1401 return false; 1431 return false;
1402 1432
1403 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) 1433 if (command_line.HasSwitch(switches::kEnableQuicPortSelection))
1404 return true; 1434 return true;
1405 1435
1406 return false; // Default to disabling port selection on all channels. 1436 return false; // Default to disabling port selection on all channels.
1407 } 1437 }
1408 1438
1439 void IOThread::RegisterSTHReporter(net::ct::STHReporter* reporter) {
1440 DCHECK(globals());
1441 // Just a sanity check to make sure it was created by now.
1442 DCHECK(globals()->cert_transparency_observer.get());
1443
1444 VLOG(1) << "XXX IOThread::RegisterWithSTHObserver";
1445
1446 // globals()->sth_observers_registrar.AssignReporter(reporter);
1447 sth_reporter_ = reporter;
1448 for (auto observer : sth_observers_) {
1449 sth_reporter_->RegisterObserver(observer);
1450 }
1451 }
1452
1453 void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) {
1454 sth_observers_.insert(observer);
1455 if (sth_reporter_) {
1456 sth_reporter_->RegisterObserver(observer);
1457 }
1458 }
1459
1460 void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) {
1461 DCHECK_NE(sth_observers_.count(observer), 0u);
1462 sth_observers_.erase(observer);
1463 if (sth_reporter_) {
1464 sth_reporter_->UnregisterObserver(observer);
1465 }
1466 }
1467
1409 net::QuicTagVector IOThread::GetQuicConnectionOptions( 1468 net::QuicTagVector IOThread::GetQuicConnectionOptions(
1410 const base::CommandLine& command_line, 1469 const base::CommandLine& command_line,
1411 const VariationParameters& quic_trial_params) { 1470 const VariationParameters& quic_trial_params) {
1412 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { 1471 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) {
1413 return net::QuicUtils::ParseQuicConnectionOptions( 1472 return net::QuicUtils::ParseQuicConnectionOptions(
1414 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); 1473 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions));
1415 } 1474 }
1416 1475
1417 VariationParameters::const_iterator it = 1476 VariationParameters::const_iterator it =
1418 quic_trial_params.find("connection_options"); 1477 quic_trial_params.find("connection_options");
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 std::move(job_factory); 1817 std::move(job_factory);
1759 1818
1760 context->set_job_factory( 1819 context->set_job_factory(
1761 globals->proxy_script_fetcher_url_request_job_factory.get()); 1820 globals->proxy_script_fetcher_url_request_job_factory.get());
1762 1821
1763 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 1822 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1764 // system URLRequestContext too. There's no reason this should be tied to a 1823 // system URLRequestContext too. There's no reason this should be tied to a
1765 // profile. 1824 // profile.
1766 return context; 1825 return context;
1767 } 1826 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698