• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DELEGATING_PROVIDER_H_
6 #define COMPONENTS_METRICS_DELEGATING_PROVIDER_H_
7 
8 #include <memory>
9 #include <vector>
10 
11 #include "components/metrics/metrics_provider.h"
12 
13 namespace metrics {
14 
15 // A MetricsProvider which manages a set of other MetricsProviders.
16 // Calls to this providers methods are forwarded to all of the registered
17 // metrics providers, allowing the group to be handled as a single provider.
18 class DelegatingProvider final : public MetricsProvider {
19  public:
20   DelegatingProvider();
21 
22   DelegatingProvider(const DelegatingProvider&) = delete;
23   DelegatingProvider& operator=(const DelegatingProvider&) = delete;
24 
25   ~DelegatingProvider() override;
26 
27   // Registers an additional MetricsProvider to forward calls to.
28   void RegisterMetricsProvider(std::unique_ptr<MetricsProvider> delegate);
29 
30   // Gets the list of registered providers.
31   const std::vector<std::unique_ptr<MetricsProvider>>& GetProviders();
32 
33   // MetricsProvider:
34   void Init() override;
35   void AsyncInit(base::OnceClosure done_callback) override;
36   void OnDidCreateMetricsLog() override;
37   void OnRecordingEnabled() override;
38   void OnRecordingDisabled() override;
39   void OnClientStateCleared() override;
40   void OnAppEnterBackground() override;
41   bool HasIndependentMetrics() override;
42   void ProvideSystemProfileMetrics(
43       SystemProfileProto* system_profile_proto) override;
44   void ProvideSystemProfileMetricsWithLogCreationTime(
45       base::TimeTicks log_creation_time,
46       SystemProfileProto* system_profile_proto) override;
47   bool HasPreviousSessionData() override;
48   void ProvidePreviousSessionData(
49       ChromeUserMetricsExtension* uma_proto) override;
50   void ProvideCurrentSessionData(
51       ChromeUserMetricsExtension* uma_proto) override;
52   void ProvideCurrentSessionUKMData() override;
53   void ClearSavedStabilityMetrics() override;
54   void RecordHistogramSnapshots(
55       base::HistogramSnapshotManager* snapshot_manager) override;
56   void RecordInitialHistogramSnapshots(
57       base::HistogramSnapshotManager* snapshot_manager) override;
58 
59  private:
60   std::vector<std::unique_ptr<MetricsProvider>> metrics_providers_;
61 };
62 
63 }  // namespace metrics
64 
65 #endif  // COMPONENTS_METRICS_DELEGATING_PROVIDER_H_
66