Commit 84e845ae authored by Daniil Lunev's avatar Daniil Lunev Committed by Commit Bot

Move kUmaStorageDimension check to provider registration site.

Bug: b:151176984
Change-Id: Ie9a8b76dffba24f464e058406bc95afe4359d31c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386946
Commit-Queue: Daniil Lunev <dlunev@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Cr-Commit-Position: refs/heads/master@{#804498}
parent 517e76b7
......@@ -60,6 +60,7 @@
#include "chrome/browser/translate/translate_ranker_metrics_provider.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
......@@ -712,8 +713,10 @@ void ChromeMetricsServiceClient::RegisterMetricsServiceProviders() {
std::make_unique<ChromeOSMetricsProvider>(
metrics::MetricsLogUploader::UMA));
if (base::FeatureList::IsEnabled(::features::kUmaStorageDimensions)) {
metrics_service_->RegisterMetricsProvider(
std::make_unique<CrosHealthdMetricsProvider>());
}
metrics_service_->RegisterMetricsProvider(
std::make_unique<SigninStatusMetricsProviderChromeOS>());
......
......@@ -8,9 +8,11 @@
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/process/process_handle.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/metrics/client_info.h"
......@@ -54,6 +56,7 @@ class ChromeMetricsServiceClientTest : public testing::Test {
base::Unretained(this)));
ASSERT_TRUE(profile_manager_.SetUp());
#if defined(OS_CHROMEOS)
scoped_feature_list_.InitAndEnableFeature(features::kUmaStorageDimensions);
// ChromeOs Metrics Provider require g_login_state and power manager client
// initialized before they can be instantiated.
chromeos::PowerManagerClient::InitializeFake();
......@@ -85,6 +88,7 @@ class ChromeMetricsServiceClientTest : public testing::Test {
base::UserActionTester user_action_runner_;
std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
metrics::TestEnabledStateProvider enabled_state_provider_;
base::test::ScopedFeatureList scoped_feature_list_;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClientTest);
......
......@@ -13,7 +13,6 @@
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/common/chrome_features.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_probe.mojom.h"
......@@ -44,12 +43,6 @@ void CrosHealthdMetricsProvider::AsyncInit(base::OnceClosure done_callback) {
init_callback_ = std::move(done_callback);
initialized_ = false;
if (!base::FeatureList::IsEnabled(::features::kUmaStorageDimensions)) {
DVLOG(1) << "cros_healthd metrics provider is not enabled";
std::move(init_callback_).Run();
return;
}
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&CrosHealthdMetricsProvider::OnProbeTimeout,
......
......@@ -10,10 +10,8 @@
#include "base/bind.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "chrome/common/chrome_features.h"
#include "chromeos/dbus/cros_healthd/cros_healthd_client.h"
#include "chromeos/dbus/cros_healthd/fake_cros_healthd_client.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
......@@ -42,7 +40,6 @@ constexpr auto kUmaPurpose =
class CrosHealthdMetricsProviderTest : public testing::Test {
public:
CrosHealthdMetricsProviderTest() {
scoped_feature_list_.InitAndEnableFeature(features::kUmaStorageDimensions);
chromeos::CrosHealthdClient::InitializeFake();
chromeos::cros_healthd::mojom::NonRemovableBlockDeviceInfo storage_info;
......@@ -82,7 +79,6 @@ class CrosHealthdMetricsProviderTest : public testing::Test {
protected:
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(CrosHealthdMetricsProviderTest, EndToEnd) {
......@@ -135,24 +131,3 @@ TEST_F(CrosHealthdMetricsProviderTest, EndToEndTimeout) {
const auto& hardware = profile.hardware();
EXPECT_EQ(0, hardware.internal_storage_devices_size());
}
TEST_F(CrosHealthdMetricsProviderTest, EndToEndNoFeature) {
scoped_feature_list_.Reset();
scoped_feature_list_.Init();
base::RunLoop run_loop;
CrosHealthdMetricsProvider provider;
provider.AsyncInit(base::BindOnce(
[](base::OnceClosure callback) { std::move(callback).Run(); },
run_loop.QuitClosure()));
run_loop.Run();
EXPECT_FALSE(provider.IsInitialized());
metrics::SystemProfileProto profile;
provider.ProvideSystemProfileMetrics(&profile);
const auto& hardware = profile.hardware();
EXPECT_EQ(0, hardware.internal_storage_devices_size());
}
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