| 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 CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | |
| 10 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
| 11 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| 12 #include "components/metrics/metrics_provider.h" | 11 #include "components/metrics/metrics_provider.h" |
| 13 #include "content/public/browser/browser_child_process_observer.h" | 12 #include "content/public/browser/browser_child_process_observer.h" |
| 14 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 16 | 15 |
| 17 class PrefRegistrySimple; | 16 class PrefRegistrySimple; |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 class RenderProcessHost; | 19 class RenderProcessHost; |
| 21 class WebContents; | 20 class WebContents; |
| 22 } | 21 } |
| 23 | 22 |
| 24 class PrefService; | |
| 25 | |
| 26 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- | 23 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- |
| 27 // related metrics. | 24 // related metrics. |
| 28 class ChromeStabilityMetricsProvider | 25 class ChromeStabilityMetricsProvider |
| 29 : public metrics::MetricsProvider, | 26 : public metrics::MetricsProvider, |
| 30 public content::BrowserChildProcessObserver, | 27 public content::BrowserChildProcessObserver, |
| 31 public content::NotificationObserver { | 28 public content::NotificationObserver { |
| 32 public: | 29 public: |
| 33 explicit ChromeStabilityMetricsProvider(PrefService* local_state); | 30 ChromeStabilityMetricsProvider(); |
| 34 ~ChromeStabilityMetricsProvider() override; | 31 ~ChromeStabilityMetricsProvider() override; |
| 35 | 32 |
| 36 // metrics::MetricsDataProvider: | 33 // metrics::MetricsDataProvider: |
| 37 void OnRecordingEnabled() override; | 34 void OnRecordingEnabled() override; |
| 38 void OnRecordingDisabled() override; | 35 void OnRecordingDisabled() override; |
| 39 void ProvideStabilityMetrics( | 36 void ProvideStabilityMetrics( |
| 40 metrics::SystemProfileProto* system_profile_proto) override; | 37 metrics::SystemProfileProto* system_profile_proto) override; |
| 41 void ClearSavedStabilityMetrics() override; | 38 void ClearSavedStabilityMetrics() override; |
| 42 | 39 |
| 43 // Registers local state prefs used by this class. | 40 // Registers local state prefs used by this class. |
| 44 static void RegisterPrefs(PrefRegistrySimple* registry); | 41 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 45 | 42 |
| 46 private: | 43 private: |
| 47 FRIEND_TEST_ALL_PREFIXES(ChromeStabilityMetricsProviderTest, | |
| 48 BrowserChildProcessObserver); | |
| 49 FRIEND_TEST_ALL_PREFIXES(ChromeStabilityMetricsProviderTest, | |
| 50 NotificationObserver); | |
| 51 | |
| 52 // content::NotificationObserver: | 44 // content::NotificationObserver: |
| 53 void Observe(int type, | 45 void Observe(int type, |
| 54 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
| 55 const content::NotificationDetails& details) override; | 47 const content::NotificationDetails& details) override; |
| 56 | 48 |
| 57 // content::BrowserChildProcessObserver: | 49 // content::BrowserChildProcessObserver: |
| 58 void BrowserChildProcessCrashed( | 50 void BrowserChildProcessCrashed( |
| 59 const content::ChildProcessData& data, | 51 const content::ChildProcessData& data, |
| 60 int exit_code) override; | 52 int exit_code) override; |
| 61 | 53 |
| 62 // Logs the initiation of a page load and uses |web_contents| to do | 54 // Logs the initiation of a page load and uses |web_contents| to do |
| 63 // additional logging of the type of page loaded. | 55 // additional logging of the type of page loaded. |
| 64 void LogLoadStarted(content::WebContents* web_contents); | 56 void LogLoadStarted(content::WebContents* web_contents); |
| 65 | 57 |
| 66 // Records a renderer process crash. | 58 // Records a renderer process crash. |
| 67 void LogRendererCrash(content::RenderProcessHost* host, | 59 void LogRendererCrash(content::RenderProcessHost* host, |
| 68 base::TerminationStatus status, | 60 base::TerminationStatus status, |
| 69 int exit_code); | 61 int exit_code); |
| 70 | 62 |
| 71 // Increment an Integer pref value specified by |path| | |
| 72 void IncrementPrefValue(const char* path); | |
| 73 | |
| 74 // Increment a 64-bit Integer pref value specified by |path| | |
| 75 void IncrementLongPrefsValue(const char* path); | |
| 76 | |
| 77 // Records a renderer process hang. | 63 // Records a renderer process hang. |
| 78 void LogRendererHang(); | 64 void LogRendererHang(); |
| 79 | 65 |
| 80 PrefService* local_state_; | |
| 81 | |
| 82 // Registrar for receiving stability-related notifications. | 66 // Registrar for receiving stability-related notifications. |
| 83 content::NotificationRegistrar registrar_; | 67 content::NotificationRegistrar registrar_; |
| 84 | 68 |
| 85 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider); | 69 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider); |
| 86 }; | 70 }; |
| 87 | 71 |
| 88 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ | 72 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ |
| OLD | NEW |