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"
17 class PrefRegistrySimple
;
20 class RenderProcessHost
;
24 namespace chromecast
{
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
{
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
;
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
,
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_