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 CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_CHROME_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 PrefRegistrySimple
;
19 class RenderProcessHost
;
23 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability-
25 class ChromeStabilityMetricsProvider
26 : public metrics::MetricsProvider
,
27 public content::BrowserChildProcessObserver
,
28 public content::NotificationObserver
{
30 ChromeStabilityMetricsProvider();
31 ~ChromeStabilityMetricsProvider() override
;
33 // metrics::MetricsDataProvider:
34 void OnRecordingEnabled() override
;
35 void OnRecordingDisabled() override
;
36 void ProvideStabilityMetrics(
37 metrics::SystemProfileProto
* system_profile_proto
) override
;
38 void ClearSavedStabilityMetrics() override
;
40 // Registers local state prefs used by this class.
41 static void RegisterPrefs(PrefRegistrySimple
* registry
);
44 // content::NotificationObserver:
45 void Observe(int type
,
46 const content::NotificationSource
& source
,
47 const content::NotificationDetails
& details
) override
;
49 // content::BrowserChildProcessObserver:
50 void BrowserChildProcessCrashed(
51 const content::ChildProcessData
& data
,
52 int exit_code
) override
;
54 // Logs the initiation of a page load and uses |web_contents| to do
55 // additional logging of the type of page loaded.
56 void LogLoadStarted(content::WebContents
* web_contents
);
58 // Records a renderer process crash.
59 void LogRendererCrash(content::RenderProcessHost
* host
,
60 base::TerminationStatus status
,
63 // Records a renderer process hang.
64 void LogRendererHang();
66 // Registrar for receiving stability-related notifications.
67 content::NotificationRegistrar registrar_
;
69 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider
);
72 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_