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> {
UtilWinService util_win_service_;
AntiVirusMetricsProvider provider_;
base::test::ScopedFeatureList scoped_feature_list_;
base::ThreadChecker thread_checker_;
base::ThreadCheckerImpl thread_checker_;
private:
DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest);
......
......@@ -247,14 +247,14 @@ ChromeMetricsServicesManagerClient::GetEnabledStateProviderForTesting() {
std::unique_ptr<rappor::RapporServiceImpl>
ChromeMetricsServicesManagerClient::CreateRapporServiceImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return std::make_unique<rappor::RapporServiceImpl>(
local_state_, base::Bind(&chrome::IsIncognitoSessionActive));
}
std::unique_ptr<variations::VariationsService>
ChromeMetricsServicesManagerClient::CreateVariationsService() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return variations::VariationsService::Create(
std::make_unique<ChromeVariationsServiceClient>(), local_state_,
GetMetricsStateManager(), switches::kDisableBackgroundNetworking,
......@@ -264,13 +264,13 @@ ChromeMetricsServicesManagerClient::CreateVariationsService() {
std::unique_ptr<metrics::MetricsServiceClient>
ChromeMetricsServicesManagerClient::CreateMetricsServiceClient() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return ChromeMetricsServiceClient::Create(GetMetricsStateManager());
}
metrics::MetricsStateManager*
ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!metrics_state_manager_) {
metrics_state_manager_ = metrics::MetricsStateManager::Create(
local_state_, enabled_state_provider_.get(), GetRegistryBackupKey(),
......
......@@ -97,7 +97,7 @@ class ChromeMetricsServicesManagerClient
std::unique_ptr<metrics::EnabledStateProvider> enabled_state_provider_;
// 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.
PrefService* const local_state_;
......
......@@ -18,7 +18,7 @@ NetworkQualityEstimatorProviderImpl::NetworkQualityEstimatorProviderImpl()
}
NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (callback_) {
g_browser_process->network_quality_tracker()
......@@ -28,7 +28,7 @@ NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() {
void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged(
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!content::BrowserThread::IsThreadInitialized(
content::BrowserThread::IO)) {
// IO thread is not yet initialized. Try again in the next message pump.
......@@ -65,7 +65,7 @@ void NetworkQualityEstimatorProviderImpl::PostReplyOnNetworkQualityChanged(
void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow(
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!callback_);
callback_ = callback;
......@@ -76,7 +76,7 @@ void NetworkQualityEstimatorProviderImpl::AddEffectiveConnectionTypeObserverNow(
void NetworkQualityEstimatorProviderImpl::OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType type) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
callback_.Run(type);
}
......
......@@ -38,7 +38,7 @@ class NetworkQualityEstimatorProviderImpl
// estimate. May be null.
base::RepeatingCallback<void(net::EffectiveConnectionType)> callback_;
base::ThreadChecker thread_checker_;
THREAD_CHECKER(thread_checker_);
base::WeakPtrFactory<NetworkQualityEstimatorProviderImpl> weak_ptr_factory_;
......
......@@ -18,7 +18,7 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration,
perf_args_(perf_args),
done_callback_(std::move(callback)),
weak_factory_(this) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
perf_data_pipe_reader_ =
std::make_unique<chromeos::PipeReader>(base::CreateTaskRunnerWithTraits(
......@@ -37,14 +37,14 @@ PerfOutputCall::PerfOutputCall(base::TimeDelta duration,
PerfOutputCall::~PerfOutputCall() {}
void PerfOutputCall::OnIOComplete(base::Optional<std::string> result) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
perf_data_pipe_reader_.reset();
std::move(done_callback_).Run(result.value_or(std::string()));
// The callback may delete us, so it's hammertime: Can't touch |this|.
}
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.
if (!result.has_value() && perf_data_pipe_reader_.get()) {
......
......@@ -48,7 +48,7 @@ class PerfOutputCall {
std::vector<std::string> perf_args_;
DoneCallback done_callback_;
base::ThreadChecker thread_checker_;
THREAD_CHECKER(thread_checker_);
// To pass around the "this" pointer across threads safely.
base::WeakPtrFactory<PerfOutputCall> weak_factory_;
......
......@@ -55,7 +55,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasForTesting() {
void SubprocessMetricsProvider::RegisterSubprocessAllocator(
int id,
std::unique_ptr<base::PersistentHistogramAllocator> allocator) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!allocators_by_id_.Lookup(id));
// Stop now if this was called without an allocator, typically because
......@@ -69,7 +69,7 @@ void SubprocessMetricsProvider::RegisterSubprocessAllocator(
}
void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!allocators_by_id_.Lookup(id))
return;
......@@ -105,7 +105,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltasFromAllocator(
}
void SubprocessMetricsProvider::MergeHistogramDeltas() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
for (AllocatorByIdMap::iterator iter(&allocators_by_id_); !iter.IsAtEnd();
iter.Advance()) {
......@@ -120,7 +120,7 @@ void SubprocessMetricsProvider::MergeHistogramDeltas() {
void SubprocessMetricsProvider::BrowserChildProcessHostConnected(
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
// managing the child in order to extract the metrics memory from it.
......@@ -137,21 +137,21 @@ void SubprocessMetricsProvider::BrowserChildProcessHostConnected(
void SubprocessMetricsProvider::BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id);
}
void SubprocessMetricsProvider::BrowserChildProcessCrashed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id);
}
void SubprocessMetricsProvider::BrowserChildProcessKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(data.id);
}
......@@ -159,7 +159,7 @@ void SubprocessMetricsProvider::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CREATED, type);
content::RenderProcessHost* host =
......@@ -173,7 +173,7 @@ void SubprocessMetricsProvider::Observe(
void SubprocessMetricsProvider::RenderProcessReady(
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
// renderer process, extract it and register it here.
......@@ -189,14 +189,14 @@ void SubprocessMetricsProvider::RenderProcessReady(
void SubprocessMetricsProvider::RenderProcessExited(
content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DeregisterSubprocessAllocator(host->GetID());
}
void SubprocessMetricsProvider::RenderProcessHostDestroyed(
content::RenderProcessHost* host) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// It's possible for a Renderer to terminate without RenderProcessExited
// (above) being called so it's necessary to de-register also upon the
......
......@@ -94,7 +94,7 @@ class SubprocessMetricsProvider
static std::unique_ptr<base::PersistentHistogramAllocator>
GetSubprocessHistogramAllocatorOnIOThread(int id);
base::ThreadChecker thread_checker_;
THREAD_CHECKER(thread_checker_);
// Object for registing notification requests.
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