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