blob: 0c36ead1579f3bc621ff8522de24249f0cb6a37f [file] [log] [blame]
Robert Kaplow0201aa3d2024-05-06 14:43:071// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_METRICS_INSTALL_DATE_PROVIDER_H_
6#define COMPONENTS_METRICS_INSTALL_DATE_PROVIDER_H_
7
8#include "base/memory/raw_ptr.h"
9#include "components/metrics/metrics_provider.h"
10#include "third_party/metrics_proto/system_profile.pb.h"
11
12class PrefService;
13
14// NOTE: This Provider is unfortunately entwined with the MetricsStateManager.
15// The MetricsStateManager actually controls the state of the pref which keeps
16// track of the install state, and also will set it.
17// Since the MetricsStateManager does quite a bit of other work, and it is
18// complex to disentangle, this provider is available if we just want the
19// install_date to be set (currently for UKM).
20// This means this Provider is *NOT* used in UMA.
21// In the longer term, we should refactor MetricsStateManager such that
22// the parts that are eligible for UKM can be reused.
23namespace metrics {
24
25// Provides the install date.
26class InstallDateProvider : public MetricsProvider {
27 public:
28 explicit InstallDateProvider(PrefService* local_state)
29 : local_state_(local_state) {}
30
31 InstallDateProvider(const InstallDateProvider&) = delete;
32 InstallDateProvider& operator=(const InstallDateProvider&) = delete;
33
34 ~InstallDateProvider() override = default;
35
36 // MetricsProvider:
37 void ProvideSystemProfileMetrics(
38 SystemProfileProto* system_profile_proto) override;
39
40 raw_ptr<PrefService> local_state_;
41};
42
43} // namespace metrics
44
45#endif // COMPONENTS_METRICS_INSTALL_DATE_PROVIDER_H_