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

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

Issue 2023253002: Merge subprocess metrics into global StatisticsRecorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added test Created 4 years, 6 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 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
(...skipping 26 matching lines...) Expand all
37 // Indicates subprocess to be monitored with unique id for later reference. 37 // Indicates subprocess to be monitored with unique id for later reference.
38 // Metrics reporting will read histograms from it and upload them to UMA. 38 // Metrics reporting will read histograms from it and upload them to UMA.
39 void RegisterSubprocessAllocator( 39 void RegisterSubprocessAllocator(
40 int id, 40 int id,
41 std::unique_ptr<base::PersistentHistogramAllocator> allocator); 41 std::unique_ptr<base::PersistentHistogramAllocator> allocator);
42 42
43 // Indicates that a subprocess has exited and is thus finished with the 43 // Indicates that a subprocess has exited and is thus finished with the
44 // allocator it was using. 44 // allocator it was using.
45 void DeregisterSubprocessAllocator(int id); 45 void DeregisterSubprocessAllocator(int id);
46 46
47 // Report all histograms of a given allocator to the snapshot-manager. 47 // Merge all histograms of a given allocator to the globalStatisticsRecorder.
48 void RecordHistogramSnapshotsFromAllocator( 48 void MergeHistogramDeltasFromAllocator(
49 base::HistogramSnapshotManager* snapshot_manager,
50 int id, 49 int id,
51 base::PersistentHistogramAllocator* allocator); 50 base::PersistentHistogramAllocator* allocator);
52 51
53 // metrics::MetricsProvider: 52 // metrics::MetricsProvider:
54 void OnDidCreateMetricsLog() override; 53 void MergeHistogramDeltas() override;
55 void OnRecordingEnabled() override;
56 void OnRecordingDisabled() override;
57 void RecordHistogramSnapshots(
58 base::HistogramSnapshotManager* snapshot_manager) override;
59 54
60 // content::NotificationObserver: 55 // content::NotificationObserver:
61 void Observe(int type, 56 void Observe(int type,
62 const content::NotificationSource& source, 57 const content::NotificationSource& source,
63 const content::NotificationDetails& details) override; 58 const content::NotificationDetails& details) override;
64 59
65 // content::RenderProcessHostObserver: 60 // content::RenderProcessHostObserver:
66 void RenderProcessReady(content::RenderProcessHost* host) override; 61 void RenderProcessReady(content::RenderProcessHost* host) override;
67 void RenderProcessExited(content::RenderProcessHost* host, 62 void RenderProcessExited(content::RenderProcessHost* host,
68 base::TerminationStatus status, 63 base::TerminationStatus status,
69 int exit_code) override; 64 int exit_code) override;
70 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; 65 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
71 66
72 base::ThreadChecker thread_checker_; 67 base::ThreadChecker thread_checker_;
73 68
74 // Object for registing notification requests. 69 // Object for registing notification requests.
75 content::NotificationRegistrar registrar_; 70 content::NotificationRegistrar registrar_;
76 71
77 // All of the shared-persistent-allocators for known sub-processes. 72 // All of the shared-persistent-allocators for known sub-processes.
78 using AllocatorByIdMap = 73 using AllocatorByIdMap =
79 IDMap<base::PersistentHistogramAllocator, IDMapOwnPointer, int>; 74 IDMap<base::PersistentHistogramAllocator, IDMapOwnPointer, int>;
80 AllocatorByIdMap allocators_by_id_; 75 AllocatorByIdMap allocators_by_id_;
81 76
82 // Allocators that are no longer attached to a subprocess, to be released
83 // once the last data contained therein has been reported.
84 std::vector<std::unique_ptr<base::PersistentHistogramAllocator>>
85 allocators_for_exited_processes_;
86 std::vector<std::unique_ptr<base::PersistentHistogramAllocator>>
87 allocators_to_release_;
88
89 // Track all observed render processes to un-observe them on exit. 77 // Track all observed render processes to un-observe them on exit.
90 ScopedObserver<content::RenderProcessHost, SubprocessMetricsProvider> 78 ScopedObserver<content::RenderProcessHost, SubprocessMetricsProvider>
91 scoped_observer_; 79 scoped_observer_;
92 80
93 // Flag indicating if metrics recording is enabled. Allocators will not
94 // live past the death of the subprocess if it is not.
95 bool metrics_recording_enabled_ = false;
96
97 DISALLOW_COPY_AND_ASSIGN(SubprocessMetricsProvider); 81 DISALLOW_COPY_AND_ASSIGN(SubprocessMetricsProvider);
98 }; 82 };
99 83
100 #endif // CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_ 84 #endif // CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698