Reorganizes Chromecast code to better reflect functional dependencies.
[chromium-blink-merge.git] / chromecast / browser / metrics / cast_stability_metrics_provider.h
blob635fc068edafe9e656083be6936f8982ed904c9a
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.
5 #ifndef CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
6 #define CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
8 #include "base/basictypes.h"
9 #include "base/metrics/user_metrics.h"
10 #include "base/process/kill.h"
11 #include "components/metrics/metrics_provider.h"
12 #include "content/public/browser/browser_child_process_observer.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 class MetricsService;
17 class PrefRegistrySimple;
19 namespace content {
20 class RenderProcessHost;
21 class WebContents;
24 namespace chromecast {
25 namespace metrics {
27 // CastStabilityMetricsProvider gathers and logs stability-related metrics.
28 // Loosely based on ChromeStabilityMetricsProvider from chrome/browser/metrics.
29 class CastStabilityMetricsProvider
30 : public ::metrics::MetricsProvider,
31 public content::BrowserChildProcessObserver,
32 public content::NotificationObserver {
33 public:
34 // Registers local state prefs used by this class.
35 static void RegisterPrefs(PrefRegistrySimple* registry);
37 CastStabilityMetricsProvider();
38 virtual ~CastStabilityMetricsProvider();
40 // metrics::MetricsDataProvider implementation:
41 virtual void OnRecordingEnabled() override;
42 virtual void OnRecordingDisabled() override;
43 virtual void ProvideStabilityMetrics(
44 ::metrics::SystemProfileProto* system_profile_proto) override;
46 private:
47 // content::NotificationObserver implementation:
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) override;
52 // content::BrowserChildProcessObserver implementation:
53 virtual void BrowserChildProcessCrashed(
54 const content::ChildProcessData& data) override;
56 // Records a renderer process crash.
57 void LogRendererCrash(content::RenderProcessHost* host,
58 base::TerminationStatus status,
59 int exit_code);
61 // Records a renderer process hang.
62 void LogRendererHang();
64 // Registrar for receiving stability-related notifications.
65 content::NotificationRegistrar registrar_;
67 DISALLOW_COPY_AND_ASSIGN(CastStabilityMetricsProvider);
70 } // namespace metrics
71 } // namespace chromecast
73 #endif // CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_