1 // Copyright 2014 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_METRICS_PROVIDER_H_ 6 #define COMPONENTS_METRICS_METRICS_PROVIDER_H_ 7 8 #include "base/basictypes.h" 9 10 namespace metrics { 11 12 class ChromeUserMetricsExtension; 13 class SystemProfileProto; 14 class SystemProfileProto_Stability; 15 16 // MetricsProvider is an interface allowing different parts of the UMA protos to 17 // be filled out by different classes. 18 class MetricsProvider { 19 public: 20 MetricsProvider(); 21 virtual ~MetricsProvider(); 22 23 // Called when a new MetricsLog is created. 24 virtual void OnDidCreateMetricsLog(); 25 26 // Called when metrics recording has been enabled. 27 virtual void OnRecordingEnabled(); 28 29 // Called when metrics recording has been disabled. 30 virtual void OnRecordingDisabled(); 31 32 // Provides additional metrics into the system profile. 33 virtual void ProvideSystemProfileMetrics( 34 SystemProfileProto* system_profile_proto); 35 36 // Called once at startup to see whether this provider has stability events 37 // to share. Default implementation always returns false. 38 virtual bool HasStabilityMetrics(); 39 40 // Provides additional stability metrics. Stability metrics can be provided 41 // directly into |stability_proto| fields or by logging stability histograms 42 // via the UMA_STABILITY_HISTOGRAM_ENUMERATION() macro. 43 virtual void ProvideStabilityMetrics( 44 SystemProfileProto* system_profile_proto); 45 46 // Called to indicate that saved stability prefs should be cleared, e.g. 47 // because they are from an old version and should not be kept. 48 virtual void ClearSavedStabilityMetrics(); 49 50 // Provides general metrics that are neither system profile nor stability 51 // metrics. May also be used to add histograms when final metrics are 52 // collected right before upload. 53 virtual void ProvideGeneralMetrics( 54 ChromeUserMetricsExtension* uma_proto); 55 56 private: 57 DISALLOW_COPY_AND_ASSIGN(MetricsProvider); 58 }; 59 60 } // namespace metrics 61 62 #endif // COMPONENTS_METRICS_METRICS_PROVIDER_H_ 63