Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 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 | |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 10 | #include "components/metrics/metrics_provider.h" |
| 11 | |
| 12 | namespace component_updater { |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame] | 13 | struct ComponentInfo; |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | namespace metrics { |
| 17 | |
| 18 | class SystemProfileProto; |
| 19 | |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame] | 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 | |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 30 | // Stores and loads system information to prefs for stability logs. |
| 31 | class ComponentMetricsProvider : public MetricsProvider { |
| 32 | public: |
| 33 | explicit ComponentMetricsProvider( |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame] | 34 | std::unique_ptr<ComponentMetricsProviderDelegate> |
| 35 | components_info_delegate); |
Peter Boström | 09c0182 | 2021-09-20 22:43:27 | [diff] [blame] | 36 | |
| 37 | ComponentMetricsProvider(const ComponentMetricsProvider&) = delete; |
| 38 | ComponentMetricsProvider& operator=(const ComponentMetricsProvider&) = delete; |
| 39 | |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 40 | ~ComponentMetricsProvider() override; |
| 41 | |
| 42 | // MetricsProvider: |
| 43 | void ProvideSystemProfileMetrics( |
| 44 | SystemProfileProto* system_profile_proto) override; |
| 45 | |
| 46 | private: |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame] | 47 | std::unique_ptr<ComponentMetricsProviderDelegate> components_info_delegate_; |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace metrics |
| 51 | |
| 52 | #endif // COMPONENTS_METRICS_COMPONENT_METRICS_PROVIDER_H_ |