OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 BLIMP_ENGINE_APP_BLIMP_STABILITY_METRICS_PROVIDER_H_ | |
6 #define BLIMP_ENGINE_APP_BLIMP_STABILITY_METRICS_PROVIDER_H_ | |
7 | |
8 #include "base/gtest_prod_util.h" | |
9 #include "base/macros.h" | |
10 #include "base/metrics/user_metrics.h" | |
11 #include "base/process/kill.h" | |
12 #include "components/metrics/metrics_provider.h" | |
13 #include "components/metrics/stability_metrics_helper.h" | |
14 #include "content/public/browser/browser_child_process_observer.h" | |
15 #include "content/public/browser/notification_observer.h" | |
16 #include "content/public/browser/notification_registrar.h" | |
17 | |
18 class PrefService; | |
19 | |
20 // BlimpStabilityMetricsProvider gathers and logs Blimp-specific stability- | |
21 // related metrics. | |
22 class BlimpStabilityMetricsProvider | |
23 : public metrics::MetricsProvider, | |
24 public content::BrowserChildProcessObserver, | |
25 public content::NotificationObserver { | |
26 public: | |
27 explicit BlimpStabilityMetricsProvider(PrefService* local_state); | |
28 ~BlimpStabilityMetricsProvider() override; | |
29 | |
30 // metrics::MetricsDataProvider: | |
31 void OnRecordingEnabled() override; | |
32 void OnRecordingDisabled() override; | |
33 void ProvideStabilityMetrics( | |
34 metrics::SystemProfileProto* system_profile_proto) override; | |
35 void ClearSavedStabilityMetrics() override; | |
36 | |
37 private: | |
38 FRIEND_TEST_ALL_PREFIXES(BlimpStabilityMetricsProviderTest, | |
39 BrowserChildProcessObserver); | |
40 FRIEND_TEST_ALL_PREFIXES(BlimpStabilityMetricsProviderTest, | |
41 NotificationObserver); | |
42 | |
43 // content::NotificationObserver: | |
44 void Observe(int type, | |
45 const content::NotificationSource& source, | |
46 const content::NotificationDetails& details) override; | |
47 | |
48 // content::BrowserChildProcessObserver: | |
49 void BrowserChildProcessCrashed( | |
50 const content::ChildProcessData& data, | |
51 int exit_code) override; | |
52 | |
53 metrics::StabilityMetricsHelper helper_; | |
54 | |
55 // Registrar for receiving stability-related notifications. | |
56 content::NotificationRegistrar registrar_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(BlimpStabilityMetricsProvider); | |
59 }; | |
60 | |
61 #endif // BLIMP_ENGINE_APP_BLIMP_STABILITY_METRICS_PROVIDER_H_ | |
OLD | NEW |