1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// found in the LICENSE file. 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/basictypes.h" 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/android/activity_type_ids.h" 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/metrics/metrics_provider.h" 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class PrefService; 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class PrefRegistrySimple; 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 15ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdochnamespace metrics { 16ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdochclass ChromeUserMetricsExtension; 17ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch} 18ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// AndroidMetricsProvider provides Android-specific stability metrics. 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class AndroidMetricsProvider : public metrics::MetricsProvider { 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Creates the AndroidMetricsProvider with the given |local_state|. 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) explicit AndroidMetricsProvider(PrefService* local_state); 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual ~AndroidMetricsProvider(); 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 26ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // metrics::MetricsProvider: 27ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch virtual void ProvideGeneralMetrics( 28ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch metrics::ChromeUserMetricsExtension* uma_proto) override; 29ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Called when the Activity that the user interacts with is swapped out. 31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // TODO(asvitkine): Expose a way for Android code to actually invoke this. 32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void OnForegroundActivityChanged(ActivityTypeIds::Type type); 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 34ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // metrics::MetricsProvider: 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ProvideStabilityMetrics( 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) metrics::SystemProfileProto* system_profile_proto) OVERRIDE; 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Registers local state prefs used by this class. 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static void RegisterPrefs(PrefRegistrySimple* registry); 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) private: 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Called to log launch and crash stats to preferences. 43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void LogStabilityToPrefs(); 44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Converts crash stats stored in the preferences into histograms. 46cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void ConvertStabilityPrefsToHistograms(); 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 48cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Weak pointer to the local state prefs store. 49cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PrefService* local_state_; 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 51cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AndroidMetricsProvider); 52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 54cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // CHROME_BROWSER_METRICS_ANDROID_METRICS_PROVIDER_H_ 55