OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ | 5 #ifndef CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ |
6 #define CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ | 6 #define CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
11 #include "components/metrics/metrics_provider.h" | 11 #include "components/metrics/metrics_provider.h" |
12 #include "content/public/browser/browser_child_process_observer.h" | 12 #include "content/public/browser/browser_child_process_observer.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 | 15 |
| 16 class MetricsService; |
16 class PrefRegistrySimple; | 17 class PrefRegistrySimple; |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class RenderProcessHost; | 20 class RenderProcessHost; |
20 class WebContents; | 21 class WebContents; |
21 } | 22 } |
22 | 23 |
23 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- | 24 namespace chromecast { |
24 // related metrics. | 25 namespace metrics { |
25 class ChromeStabilityMetricsProvider | 26 |
26 : public metrics::MetricsProvider, | 27 // CastStabilityMetricsProvider gathers and logs stability-related metrics. |
| 28 // Loosely based on ChromeStabilityMetricsProvider from chrome/browser/metrics. |
| 29 class CastStabilityMetricsProvider |
| 30 : public ::metrics::MetricsProvider, |
27 public content::BrowserChildProcessObserver, | 31 public content::BrowserChildProcessObserver, |
28 public content::NotificationObserver { | 32 public content::NotificationObserver { |
29 public: | 33 public: |
30 ChromeStabilityMetricsProvider(); | 34 // Registers local state prefs used by this class. |
31 virtual ~ChromeStabilityMetricsProvider(); | 35 static void RegisterPrefs(PrefRegistrySimple* registry); |
32 | 36 |
33 // metrics::MetricsDataProvider: | 37 CastStabilityMetricsProvider(); |
| 38 virtual ~CastStabilityMetricsProvider(); |
| 39 |
| 40 // metrics::MetricsDataProvider implementation: |
34 virtual void OnRecordingEnabled() OVERRIDE; | 41 virtual void OnRecordingEnabled() OVERRIDE; |
35 virtual void OnRecordingDisabled() OVERRIDE; | 42 virtual void OnRecordingDisabled() OVERRIDE; |
36 virtual void ProvideStabilityMetrics( | 43 virtual void ProvideStabilityMetrics( |
37 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; | 44 ::metrics::SystemProfileProto* system_profile_proto) OVERRIDE; |
38 virtual void ClearSavedStabilityMetrics() OVERRIDE; | |
39 | |
40 // Registers local state prefs used by this class. | |
41 static void RegisterPrefs(PrefRegistrySimple* registry); | |
42 | 45 |
43 private: | 46 private: |
44 // content::NotificationObserver: | 47 // content::NotificationObserver implementation: |
45 virtual void Observe(int type, | 48 virtual void Observe(int type, |
46 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
47 const content::NotificationDetails& details) OVERRIDE; | 50 const content::NotificationDetails& details) OVERRIDE; |
48 | 51 |
49 // content::BrowserChildProcessObserver: | 52 // content::BrowserChildProcessObserver implementation: |
50 virtual void BrowserChildProcessCrashed( | 53 virtual void BrowserChildProcessCrashed( |
51 const content::ChildProcessData& data) OVERRIDE; | 54 const content::ChildProcessData& data) OVERRIDE; |
52 | 55 |
53 // Logs the initiation of a page load and uses |web_contents| to do | |
54 // additional logging of the type of page loaded. | |
55 void LogLoadStarted(content::WebContents* web_contents); | |
56 | |
57 // Records a renderer process crash. | 56 // Records a renderer process crash. |
58 void LogRendererCrash(content::RenderProcessHost* host, | 57 void LogRendererCrash(content::RenderProcessHost* host, |
59 base::TerminationStatus status, | 58 base::TerminationStatus status, |
60 int exit_code); | 59 int exit_code); |
61 | 60 |
62 // Records a renderer process hang. | 61 // Records a renderer process hang. |
63 void LogRendererHang(); | 62 void LogRendererHang(); |
64 | 63 |
65 // Registrar for receiving stability-related notifications. | 64 // Registrar for receiving stability-related notifications. |
66 content::NotificationRegistrar registrar_; | 65 content::NotificationRegistrar registrar_; |
67 | 66 |
68 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider); | 67 DISALLOW_COPY_AND_ASSIGN(CastStabilityMetricsProvider); |
69 }; | 68 }; |
70 | 69 |
71 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ | 70 } // namespace metrics |
| 71 } // namespace chromecast |
| 72 |
| 73 #endif // CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ |
OLD | NEW |