OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ | |
6 #define CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ | |
7 | |
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" | |
15 | |
16 class MetricsService; | |
17 class PrefRegistrySimple; | |
18 | |
19 namespace content { | |
20 class RenderProcessHost; | |
21 class WebContents; | |
22 } | |
23 | |
24 namespace chromecast { | |
25 namespace metrics { | |
26 | |
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); | |
36 | |
37 CastStabilityMetricsProvider(); | |
38 virtual ~CastStabilityMetricsProvider(); | |
39 | |
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; | |
45 | |
46 private: | |
47 // content::NotificationObserver implementation: | |
48 virtual void Observe(int type, | |
49 const content::NotificationSource& source, | |
50 const content::NotificationDetails& details) override; | |
51 | |
52 // content::BrowserChildProcessObserver implementation: | |
53 virtual void BrowserChildProcessCrashed( | |
54 const content::ChildProcessData& data) override; | |
55 | |
56 // Records a renderer process crash. | |
57 void LogRendererCrash(content::RenderProcessHost* host, | |
58 base::TerminationStatus status, | |
59 int exit_code); | |
60 | |
61 // Records a renderer process hang. | |
62 void LogRendererHang(); | |
63 | |
64 // Registrar for receiving stability-related notifications. | |
65 content::NotificationRegistrar registrar_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(CastStabilityMetricsProvider); | |
68 }; | |
69 | |
70 } // namespace metrics | |
71 } // namespace chromecast | |
72 | |
73 #endif // CHROMECAST_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_ | |
OLD | NEW |