Commit 9e568ff3 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

//chrome/browser/metrics: Fix base::ThreadChecker presubmit warnings

Bug: 930523
Change-Id: I217f7ef6af0e2aa5d29f88ee1f4a4a1cb5b04815
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1536061
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644829}
parent 72ab653f
...@@ -103,7 +103,7 @@ class AntiVirusMetricsProviderTest : public ::testing::TestWithParam<bool> { ...@@ -103,7 +103,7 @@ class AntiVirusMetricsProviderTest : public ::testing::TestWithParam<bool> {
UtilWinService util_win_service_; UtilWinService util_win_service_;
AntiVirusMetricsProvider provider_; AntiVirusMetricsProvider provider_;
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
base::ThreadChecker thread_checker_; base::ThreadCheckerImpl thread_checker_;
private: private:
DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest);
......
...@@ -247,14 +247,14 @@ ChromeMetricsServicesManagerClient::GetEnabledStateProviderForTesting() { ...@@ -247,14 +247,14 @@ ChromeMetricsServicesManagerClient::GetEnabledStateProviderForTesting() {
std::unique_ptr<rappor::RapporServiceImpl> std::unique_ptr<rappor::RapporServiceImpl>
ChromeMetricsServicesManagerClient::CreateRapporServiceImpl() { ChromeMetricsServicesManagerClient::CreateRapporServiceImpl() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return std::make_unique<rappor::RapporServiceImpl>( return std::make_unique<rappor::RapporServiceImpl>(
local_state_, base::Bind(&chrome::IsIncognitoSessionActive)); local_state_, base::Bind(&chrome::IsIncognitoSessionActive));
} }
std::unique_ptr<variations::VariationsService> std::unique_ptr<variations::VariationsService>
ChromeMetricsServicesManagerClient::CreateVariationsService() { ChromeMetricsServicesManagerClient::CreateVariationsService() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return variations::VariationsService::Create( return variations::VariationsService::Create(
std::make_unique<ChromeVariationsServiceClient>(), local_state_, std::make_unique<ChromeVariationsServiceClient>(), local_state_,
GetMetricsStateManager(), switches::kDisableBackgroundNetworking, GetMetricsStateManager(), switches::kDisableBackgroundNetworking,
...@@ -264,13 +264,13 @@ ChromeMetricsServicesManagerClient::CreateVariationsService() { ...@@ -264,13 +264,13 @@ ChromeMetricsServicesManagerClient::CreateVariationsService() {
std::unique_ptr<metrics::MetricsServiceClient> std::unique_ptr<metrics::MetricsServiceClient>
ChromeMetricsServicesManagerClient::CreateMetricsServiceClient() { ChromeMetricsServicesManagerClient::CreateMetricsServiceClient() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return ChromeMetricsServiceClient::Create(GetMetricsStateManager()); return ChromeMetricsServiceClient::Create(GetMetricsStateManager());
} }
metrics::MetricsStateManager* metrics::MetricsStateManager*
ChromeMetricsServicesManagerClient::GetMetricsStateManager() { ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!metrics_state_manager_) { if (!metrics_state_manager_) {
metrics_state_manager_ = metrics::MetricsStateManager::Create( metrics_state_manager_ = metrics::MetricsStateManager::Create(
local_state_, enabled_state_provider_.get(), GetRegistryBackupKey(), local_state_, enabled_state_provider_.get(), GetRegistryBackupKey(),
......
...@@ -97,7 +97,7 @@ class ChromeMetricsServicesManagerClient ...@@ -97,7 +97,7 @@ class ChromeMetricsServicesManagerClient
std::unique_ptr<metrics::EnabledStateProvider> enabled_state_provider_; std::unique_ptr<metrics::EnabledStateProvider> enabled_state_provider_;
// Ensures that all functions are called from the same thread. // Ensures that all functions are called from the same thread.
base::ThreadChecker thread_checker_; THREAD_CHECKER(thread_checker_);
// Weak pointer to the local state prefs store. // Weak pointer to the local state prefs store.
PrefService* const local_state_; PrefService* const local_state_;
......
...@@ -18,7 +18,7 @@ NetworkQualityEstimatorProviderImpl::NetworkQualityEstimatorProviderImpl() ...@@ -18,7 +18,7 @@ NetworkQualityEstimatorProviderImpl::NetworkQualityEstimatorProviderImpl()
} }
NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() { NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (callback_) { if (callback_) {
g_browser_process->network_quality_tracker() g_browser_process->network_quality_tracker()
...@@ -28,7 +28,7 @@ NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() { ...@@ -28,7 +28,7 @@ NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() {
void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged( void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged(
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) { base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!content::BrowserThread::IsThreadInitialized( if (!content::BrowserThread::IsThreadInitialized(
content::BrowserThread::IO)) { content::BrowserThread::IO)) {
// IO thread is not yet initialized. Try again in the next message pump. // IO thread is not yet initialized. Try again in the next message pump.
...@@ -65,7 +65,7 @@ void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged( ...@@ -65,7 +65,7 @@ void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged(
void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow( void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow(
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) { base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!callback_); DCHECK(!callback_);
callback_ = callback; callback_ = callback;
...@@ -76,7 +76,7 @@ void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow( ...@@ -76,7 +76,7 @@ void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow(
void NetworkQualityEstimatorProviderImpl::OnEffectiveConnectionTypeChanged( void NetworkQualityEstimatorProviderImpl::OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType type) { net::EffectiveConnectionType type) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
callback_.Run(type); callback_.Run(type);
} }
......
...@@ -38,7 +38,7 @@ class NetworkQualityEstimatorProviderImpl ...@@ -38,7 +38,7 @@ class NetworkQualityEstimatorProviderImpl
// estimate. May be null. // estimate. May be null.
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback_; base::RepeatingCallback<void(net::EffectiveConnectionType)> callback_;
base::ThreadChecker thread_checker_; THREAD_CHECKER(thread_checker_);
base::WeakPtrFactory<NetworkQualityEstimatorProviderImpl> weak_ptr_factory_; base::WeakPtrFactory<NetworkQualityEstimatorProviderImpl> weak_ptr_factory_;
......
...@@ -18,7 +18,7 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration, ...@@ -18,7 +18,7 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration,
perf_args_(perf_args), perf_args_(perf_args),
done_callback_(std::move(callback)), done_callback_(std::move(callback)),
weak_factory_(this) { weak_factory_(this) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
perf_data_pipe_reader_ = perf_data_pipe_reader_ =
std::make_unique<chromeos::PipeReader>(base::CreateTaskRunnerWithTraits( std::make_unique<chromeos::PipeReader>(base::CreateTaskRunnerWithTraits(
...@@ -37,14 +37,14 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration, ...@@ -37,14 +37,14 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration,
PerfOutputCall::~PerfOutputCall() {} PerfOutputCall::~PerfOutputCall() {}
void PerfOutputCall::OnIOComplete(base::Optional<std::string> result) { void PerfOutputCall::OnIOComplete(base::Optional<std::string> result) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
perf_data_pipe_reader_.reset(); perf_data_pipe_reader_.reset();
std::move(done_callback_).Run(result.value_or(std::string())); std::move(done_callback_).Run(result.value_or(std::string()));
// The callback may delete us, so it's hammertime: Can't touch |this|. // The callback may delete us, so it's hammertime: Can't touch |this|.
} }
void PerfOutputCall::OnGetPerfOutput(base::Optional<uint64_t> result) { void PerfOutputCall::OnGetPerfOutput(base::Optional<uint64_t> result) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// Signal pipe reader to shut down. // Signal pipe reader to shut down.
if (!result.has_value() && perf_data_pipe_reader_.get()) { if (!result.has_value() && perf_data_pipe_reader_.get()) {
......
...@@ -48,7 +48,7 @@ class PerfOutputCall { ...@@ -48,7 +48,7 @@ class PerfOutputCall {
std::vector<std::string> perf_args_; std::vector<std::string> perf_args_;
DoneCallback done_callback_; DoneCallback done_callback_;
base::ThreadChecker thread_checker_; THREAD_CHECKER(thread_checker_);
// To pass around the "this" pointer across threads safely. // To pass around the "this" pointer across threads safely.
base::WeakPtrFactory<PerfOutputCall> weak_factory_; base::WeakPtrFactory<PerfOutputCall> weak_factory_;
......
...@@ -55,7 +55,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasForTesting() { ...@@ -55,7 +55,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasForTesting() {
void SubprocessMetricsProvider::RegisterSubprocessAllocator( void SubprocessMetricsProvider::RegisterSubprocessAllocator(
int id, int id,
std::unique_ptr<base::PersistentHistogramAllocator> allocator) { std::unique_ptr<base::PersistentHistogramAllocator> allocator) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!allocators_by_id_.Lookup(id)); DCHECK(!allocators_by_id_.Lookup(id));
// Stop now if this was called without an allocator, typically because // Stop now if this was called without an allocator, typically because
...@@ -69,7 +69,7 @@ void SubprocessMetricsProvider::RegisterSubprocessAllocator( ...@@ -69,7 +69,7 @@ void SubprocessMetricsProvider::RegisterSubprocessAllocator(
} }
void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) { void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!allocators_by_id_.Lookup(id)) if (!allocators_by_id_.Lookup(id))
return; return;
...@@ -105,7 +105,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasFromAllocator( ...@@ -105,7 +105,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasFromAllocator(
} }
void SubprocessMetricsProvider::MergeHistogramDeltas() { void SubprocessMetricsProvider::MergeHistogramDeltas() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
for (AllocatorByIdMap::iterator iter(&allocators_by_id_); !iter.IsAtEnd(); for (AllocatorByIdMap::iterator iter(&allocators_by_id_); !iter.IsAtEnd();
iter.Advance()) { iter.Advance()) {
...@@ -120,7 +120,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltas() { ...@@ -120,7 +120,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltas() {
void SubprocessMetricsProvider::BrowserChildProcessHostConnected( void SubprocessMetricsProvider::BrowserChildProcessHostConnected(
const content::ChildProcessData& data) { const content::ChildProcessData& data) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// It's necessary to access the BrowserChildProcessHost object that is // It's necessary to access the BrowserChildProcessHost object that is
// managing the child in order to extract the metrics memory from it. // managing the child in order to extract the metrics memory from it.
...@@ -137,21 +137,21 @@ void SubprocessMetricsProvider::BrowserChildProcessHostConnected( ...@@ -137,21 +137,21 @@ void SubprocessMetricsProvider::BrowserChildProcessHostConnected(
void SubprocessMetricsProvider::BrowserChildProcessHostDisconnected( void SubprocessMetricsProvider::BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) { const content::ChildProcessData& data) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id); DeregisterSubprocessAllocator(data.id);
} }
void SubprocessMetricsProvider::BrowserChildProcessCrashed( void SubprocessMetricsProvider::BrowserChildProcessCrashed(
const content::ChildProcessData& data, const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id); DeregisterSubprocessAllocator(data.id);
} }
void SubprocessMetricsProvider::BrowserChildProcessKilled( void SubprocessMetricsProvider::BrowserChildProcessKilled(
const content::ChildProcessData& data, const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id); DeregisterSubprocessAllocator(data.id);
} }
...@@ -159,7 +159,7 @@ void SubprocessMetricsProvider::Observe( ...@@ -159,7 +159,7 @@ void SubprocessMetricsProvider::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CREATED, type); DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CREATED, type);
content::RenderProcessHost* host = content::RenderProcessHost* host =
...@@ -173,7 +173,7 @@ void SubprocessMetricsProvider::Observe( ...@@ -173,7 +173,7 @@ void SubprocessMetricsProvider::Observe(
void SubprocessMetricsProvider::RenderProcessReady( void SubprocessMetricsProvider::RenderProcessReady(
content::RenderProcessHost* host) { content::RenderProcessHost* host) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// If the render-process-host passed a persistent-memory-allocator to the // If the render-process-host passed a persistent-memory-allocator to the
// renderer process, extract it and register it here. // renderer process, extract it and register it here.
...@@ -189,14 +189,14 @@ void SubprocessMetricsProvider::RenderProcessReady( ...@@ -189,14 +189,14 @@ void SubprocessMetricsProvider::RenderProcessReady(
void SubprocessMetricsProvider::RenderProcessExited( void SubprocessMetricsProvider::RenderProcessExited(
content::RenderProcessHost* host, content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(host->GetID()); DeregisterSubprocessAllocator(host->GetID());
} }
void SubprocessMetricsProvider::RenderProcessHostDestroyed( void SubprocessMetricsProvider::RenderProcessHostDestroyed(
content::RenderProcessHost* host) { content::RenderProcessHost* host) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// It's possible for a Renderer to terminate without RenderProcessExited // It's possible for a Renderer to terminate without RenderProcessExited
// (above) being called so it's necessary to de-register also upon the // (above) being called so it's necessary to de-register also upon the
......
...@@ -94,7 +94,7 @@ class SubprocessMetricsProvider ...@@ -94,7 +94,7 @@ class SubprocessMetricsProvider
static std::unique_ptr<base::PersistentHistogramAllocator> static std::unique_ptr<base::PersistentHistogramAllocator>
GetSubprocessHistogramAllocatorOnIOThread(int id); GetSubprocessHistogramAllocatorOnIOThread(int id);
base::ThreadChecker thread_checker_; THREAD_CHECKER(thread_checker_);
// Object for registing notification requests. // Object for registing notification requests.
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment