[email protected] | 6ba11eb | 2014-05-22 08:17:46 | [diff] [blame] | 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 CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ |
| 6 | #define CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "chrome/browser/android/activity_type_ids.h" |
| 10 | #include "components/metrics/metrics_provider.h" |
| 11 | |
| 12 | class PrefService; |
| 13 | class PrefRegistrySimple; |
| 14 | |
mariakhomenko | 19102898 | 2014-10-20 23:22:56 | [diff] [blame^] | 15 | namespace metrics { |
| 16 | class ChromeUserMetricsExtension; |
| 17 | } |
| 18 | |
[email protected] | 6ba11eb | 2014-05-22 08:17:46 | [diff] [blame] | 19 | // AndroidMetricsProvider provides Android-specific stability metrics. |
| 20 | class AndroidMetricsProvider : public metrics::MetricsProvider { |
| 21 | public: |
| 22 | // Creates the AndroidMetricsProvider with the given |local_state|. |
| 23 | explicit AndroidMetricsProvider(PrefService* local_state); |
| 24 | virtual ~AndroidMetricsProvider(); |
| 25 | |
mariakhomenko | 19102898 | 2014-10-20 23:22:56 | [diff] [blame^] | 26 | // metrics::MetricsProvider: |
| 27 | virtual void ProvideGeneralMetrics( |
| 28 | metrics::ChromeUserMetricsExtension* uma_proto) override; |
| 29 | |
[email protected] | 6ba11eb | 2014-05-22 08:17:46 | [diff] [blame] | 30 | // Called when the Activity that the user interacts with is swapped out. |
| 31 | // TODO(asvitkine): Expose a way for Android code to actually invoke this. |
| 32 | void OnForegroundActivityChanged(ActivityTypeIds::Type type); |
| 33 | |
mariakhomenko | 19102898 | 2014-10-20 23:22:56 | [diff] [blame^] | 34 | // metrics::MetricsProvider: |
[email protected] | 6ba11eb | 2014-05-22 08:17:46 | [diff] [blame] | 35 | virtual void ProvideStabilityMetrics( |
mostynb | 2b52d1db | 2014-10-07 02:47:17 | [diff] [blame] | 36 | metrics::SystemProfileProto* system_profile_proto) override; |
[email protected] | 6ba11eb | 2014-05-22 08:17:46 | [diff] [blame] | 37 | |
| 38 | // Registers local state prefs used by this class. |
| 39 | static void RegisterPrefs(PrefRegistrySimple* registry); |
| 40 | |
| 41 | private: |
| 42 | // Called to log launch and crash stats to preferences. |
| 43 | void LogStabilityToPrefs(); |
| 44 | |
| 45 | // Converts crash stats stored in the preferences into histograms. |
| 46 | void ConvertStabilityPrefsToHistograms(); |
| 47 | |
| 48 | // Weak pointer to the local state prefs store. |
| 49 | PrefService* local_state_; |
| 50 | |
| 51 | DISALLOW_COPY_AND_ASSIGN(AndroidMetricsProvider); |
| 52 | }; |
| 53 | |
| 54 | #endif // CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ |