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); |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 36 | ~ComponentMetricsProvider() override; |
| 37 | |
| 38 | // MetricsProvider: |
| 39 | void ProvideSystemProfileMetrics( |
| 40 | SystemProfileProto* system_profile_proto) override; |
| 41 | |
| 42 | private: |
Hazem Ashmawy | 037270b | 2021-09-01 12:12:04 | [diff] [blame^] | 43 | std::unique_ptr<ComponentMetricsProviderDelegate> components_info_delegate_; |
Joshua Pawlicki | 0499ac8 | 2017-08-17 18:29:07 | [diff] [blame] | 44 | |
| 45 | DISALLOW_COPY_AND_ASSIGN(ComponentMetricsProvider); |
| 46 | }; |
| 47 | |
| 48 | } // namespace metrics |
| 49 | |
| 50 | #endif // COMPONENTS_METRICS_COMPONENT_METRICS_PROVIDER_H_ |