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