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

Unified Diff: base/metrics/statistics_recorder.cc

Issue 2358023003: Call StatisticsRecorder::Initialize when a GlobalHistogramAllocator is created. (Closed)
Patch Set: removed debugging code Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.cc
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index a53f8f2a3c82f9a52f5e84a0930d158af0e189f8..6b1b0bfdea211e152e30929cac8216479a09786b 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -93,6 +93,17 @@ StatisticsRecorder::~StatisticsRecorder() {
// static
void StatisticsRecorder::Initialize() {
+ // Tests sometimes create local StatisticsRecorders in order to provide a
+ // contained environment of histograms that can be later discarded. If a
+ // true global instance gets created in this environment then it will
+ // eventually get disconnected when the local instance destructs and
+ // restores the previous state, resulting in no StatisticsRecorder at all.
+ // The global lazy instance, however, will remain valid thus ensuring that
+ // another never gets installed via this method. If a |histograms_| map
+ // exists then assume the StatisticsRecorder is already "initialized".
+ if (histograms_)
+ return;
+
// Ensure that an instance of the StatisticsRecorder object is created.
g_statistics_recorder_.Get();
}
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698