1 // 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 12 class 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. 23 namespace metrics { 24 25 // Provides the install date. 26 class InstallDateProvider : public MetricsProvider { 27 public: InstallDateProvider(PrefService * local_state)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_ 46