OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_SUBPROCESS_METRICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ |
6 #define CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/metrics/statistics_recorder.h" |
14 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
16 #include "components/metrics/metrics_provider.h" | 17 #include "components/metrics/metrics_provider.h" |
17 #include "content/public/browser/browser_child_process_observer.h" | 18 #include "content/public/browser/browser_child_process_observer.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/render_process_host_observer.h" | 21 #include "content/public/browser/render_process_host_observer.h" |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class PersistentHistogramAllocator; | 24 class PersistentHistogramAllocator; |
24 } | 25 } |
25 | 26 |
26 // SubprocessMetricsProvider gathers and merges histograms stored in shared | 27 // SubprocessMetricsProvider gathers and merges histograms stored in shared |
27 // memory segments between processes. Merging occurs when a process exits, | 28 // memory segments between processes. Merging occurs when a process exits, |
28 // when metrics are being collected for upload, or when something else needs | 29 // when metrics are being collected for upload, or when something else needs |
29 // combined metrics (such as the chrome://histograms page). | 30 // combined metrics (such as the chrome://histograms page). |
30 class SubprocessMetricsProvider : public metrics::MetricsProvider, | 31 class SubprocessMetricsProvider |
31 public content::BrowserChildProcessObserver, | 32 : public metrics::MetricsProvider, |
32 public content::NotificationObserver, | 33 public base::StatisticsRecorder::HistogramProvider, |
33 public content::RenderProcessHostObserver { | 34 public content::BrowserChildProcessObserver, |
| 35 public content::NotificationObserver, |
| 36 public content::RenderProcessHostObserver { |
34 public: | 37 public: |
35 SubprocessMetricsProvider(); | 38 SubprocessMetricsProvider(); |
36 ~SubprocessMetricsProvider() override; | 39 ~SubprocessMetricsProvider() override; |
37 | 40 |
38 // Merge histograms for all subprocesses. This is used by tests that don't | 41 // Merge histograms for all subprocesses. This is used by tests that don't |
39 // have access to the internal instance of this class. | 42 // have access to the internal instance of this class. |
40 static void MergeHistogramDeltasForTesting(); | 43 static void MergeHistogramDeltasForTesting(); |
41 | 44 |
42 private: | 45 private: |
43 friend class SubprocessMetricsProviderTest; | 46 friend class SubprocessMetricsProviderTest; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Track all observed render processes to un-observe them on exit. | 107 // Track all observed render processes to un-observe them on exit. |
105 ScopedObserver<content::RenderProcessHost, SubprocessMetricsProvider> | 108 ScopedObserver<content::RenderProcessHost, SubprocessMetricsProvider> |
106 scoped_observer_; | 109 scoped_observer_; |
107 | 110 |
108 base::WeakPtrFactory<SubprocessMetricsProvider> weak_ptr_factory_; | 111 base::WeakPtrFactory<SubprocessMetricsProvider> weak_ptr_factory_; |
109 | 112 |
110 DISALLOW_COPY_AND_ASSIGN(SubprocessMetricsProvider); | 113 DISALLOW_COPY_AND_ASSIGN(SubprocessMetricsProvider); |
111 }; | 114 }; |
112 | 115 |
113 #endif // CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ | 116 #endif // CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ |
OLD | NEW |