Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(850)

Side by Side Diff: chrome/browser/metrics/chrome_stability_metrics_provider.h

Issue 1323703002: Add tests for Chrome Stability Metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change to testing::Test and add extension test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
10 #include "base/process/kill.h" 11 #include "base/process/kill.h"
11 #include "components/metrics/metrics_provider.h" 12 #include "components/metrics/metrics_provider.h"
12 #include "content/public/browser/browser_child_process_observer.h" 13 #include "content/public/browser/browser_child_process_observer.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 16
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
24 class PrefService;
25
23 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- 26 // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability-
24 // related metrics. 27 // related metrics.
25 class ChromeStabilityMetricsProvider 28 class ChromeStabilityMetricsProvider
26 : public metrics::MetricsProvider, 29 : public metrics::MetricsProvider,
27 public content::BrowserChildProcessObserver, 30 public content::BrowserChildProcessObserver,
28 public content::NotificationObserver { 31 public content::NotificationObserver {
29 public: 32 public:
30 ChromeStabilityMetricsProvider(); 33 explicit ChromeStabilityMetricsProvider(PrefService* local_state);
31 ~ChromeStabilityMetricsProvider() override; 34 ~ChromeStabilityMetricsProvider() override;
32 35
33 // metrics::MetricsDataProvider: 36 // metrics::MetricsDataProvider:
34 void OnRecordingEnabled() override; 37 void OnRecordingEnabled() override;
35 void OnRecordingDisabled() override; 38 void OnRecordingDisabled() override;
36 void ProvideStabilityMetrics( 39 void ProvideStabilityMetrics(
37 metrics::SystemProfileProto* system_profile_proto) override; 40 metrics::SystemProfileProto* system_profile_proto) override;
38 void ClearSavedStabilityMetrics() override; 41 void ClearSavedStabilityMetrics() override;
39 42
40 // Registers local state prefs used by this class. 43 // Registers local state prefs used by this class.
41 static void RegisterPrefs(PrefRegistrySimple* registry); 44 static void RegisterPrefs(PrefRegistrySimple* registry);
42 45
43 private: 46 private:
47 FRIEND_TEST_ALL_PREFIXES(ChromeStabilityMetricsProviderTest,
48 BrowserChildProcessObserver);
49 FRIEND_TEST_ALL_PREFIXES(ChromeStabilityMetricsProviderTest,
50 NotificationObserver);
51
44 // content::NotificationObserver: 52 // content::NotificationObserver:
45 void Observe(int type, 53 void Observe(int type,
46 const content::NotificationSource& source, 54 const content::NotificationSource& source,
47 const content::NotificationDetails& details) override; 55 const content::NotificationDetails& details) override;
48 56
49 // content::BrowserChildProcessObserver: 57 // content::BrowserChildProcessObserver:
50 void BrowserChildProcessCrashed( 58 void BrowserChildProcessCrashed(
51 const content::ChildProcessData& data, 59 const content::ChildProcessData& data,
52 int exit_code) override; 60 int exit_code) override;
53 61
54 // Logs the initiation of a page load and uses |web_contents| to do 62 // Logs the initiation of a page load and uses |web_contents| to do
55 // additional logging of the type of page loaded. 63 // additional logging of the type of page loaded.
56 void LogLoadStarted(content::WebContents* web_contents); 64 void LogLoadStarted(content::WebContents* web_contents);
57 65
58 // Records a renderer process crash. 66 // Records a renderer process crash.
59 void LogRendererCrash(content::RenderProcessHost* host, 67 void LogRendererCrash(content::RenderProcessHost* host,
60 base::TerminationStatus status, 68 base::TerminationStatus status,
61 int exit_code); 69 int exit_code);
62 70
71 // Increment an Integer pref value specified by |path|
Avi (use Gerrit) 2015/09/02 01:11:10 . at the end of sentences
Will Harris 2015/09/02 15:57:53 Done.
72 void IncrementPrefValue(const char* path);
73
74 // Increment a 64-bit Integer pref value specified by |path|
Avi (use Gerrit) 2015/09/02 01:11:10 ditto
Will Harris 2015/09/02 15:57:53 Done.
75 void IncrementLongPrefsValue(const char* path);
76
63 // Records a renderer process hang. 77 // Records a renderer process hang.
64 void LogRendererHang(); 78 void LogRendererHang();
65 79
80 PrefService* local_state_;
81
66 // Registrar for receiving stability-related notifications. 82 // Registrar for receiving stability-related notifications.
67 content::NotificationRegistrar registrar_; 83 content::NotificationRegistrar registrar_;
68 84
69 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider); 85 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider);
70 }; 86 };
71 87
72 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ 88 #endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698