1 // Copyright 2017 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_COMPONENT_METRICS_PROVIDER_H_ 6 #define COMPONENTS_METRICS_COMPONENT_METRICS_PROVIDER_H_ 7 8 #include <vector> 9 10 #include "components/metrics/metrics_provider.h" 11 12 namespace component_updater { 13 struct ComponentInfo; 14 } 15 16 namespace metrics { 17 18 class SystemProfileProto; 19 20 // A delegate that returns a list of components that are loaded in the 21 // system. 22 class ComponentMetricsProviderDelegate { 23 public: 24 ComponentMetricsProviderDelegate() = default; 25 virtual ~ComponentMetricsProviderDelegate() = default; 26 27 virtual std::vector<component_updater::ComponentInfo> GetComponents() = 0; 28 }; 29 30 // Stores and loads system information to prefs for stability logs. 31 class ComponentMetricsProvider : public MetricsProvider { 32 public: 33 explicit ComponentMetricsProvider( 34 std::unique_ptr<ComponentMetricsProviderDelegate> 35 components_info_delegate); 36 37 ComponentMetricsProvider(const ComponentMetricsProvider&) = delete; 38 ComponentMetricsProvider& operator=(const ComponentMetricsProvider&) = delete; 39 40 ~ComponentMetricsProvider() override; 41 42 // MetricsProvider: 43 void ProvideSystemProfileMetrics( 44 SystemProfileProto* system_profile_proto) override; 45 46 private: 47 std::unique_ptr<ComponentMetricsProviderDelegate> components_info_delegate_; 48 }; 49 50 } // namespace metrics 51 52 #endif // COMPONENTS_METRICS_COMPONENT_METRICS_PROVIDER_H_ 53