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

Unified Diff: base/metrics/statistics_recorder.h

Issue 1748403003: Log histograms on shutdown when verbose logging is on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 5 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 | « no previous file | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.h
diff --git a/base/metrics/statistics_recorder.h b/base/metrics/statistics_recorder.h
index 002758e840e1aa404409e6a14785615e790c9ce5..c3c6aceffd70cb3862337c7905eeb8e38c75b837 100644
--- a/base/metrics/statistics_recorder.h
+++ b/base/metrics/statistics_recorder.h
@@ -167,6 +167,12 @@ class BASE_EXPORT StatisticsRecorder {
// Returns the number of known histograms.
static size_t GetHistogramCount();
+ // Initializes logging histograms with --v=1. Safe to call multiple times.
+ // Is called from ctor but for browser it seems that it is more useful to
+ // start logging after statistics recorder, so we need to init log-on-shutdown
+ // later.
+ static void InitLogOnShutdown();
+
// Removes a histogram from the internal set of known ones. This can be
// necessary during testing persistent histograms where the underlying
// memory is being released.
@@ -195,6 +201,7 @@ class BASE_EXPORT StatisticsRecorder {
typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap;
friend struct DefaultLazyInstanceTraits<StatisticsRecorder>;
+ friend class StatisticsRecorderTest;
// Imports histograms from global persistent memory. The global lock must
// not be held during this call.
@@ -205,6 +212,10 @@ class BASE_EXPORT StatisticsRecorder {
// call the constructor to get a clean StatisticsRecorder.
StatisticsRecorder();
+ // Initialize implementation but without lock. Caller should guard
+ // StatisticsRecorder by itself if needed (it isn't in unit tests).
+ void InitLogOnShutdownWithoutLock();
+
// These are copies of everything that existed when the (test) Statistics-
// Recorder was created. The global ones have to be moved aside to create a
// clean environment.
@@ -212,6 +223,8 @@ class BASE_EXPORT StatisticsRecorder {
std::unique_ptr<CallbackMap> existing_callbacks_;
std::unique_ptr<RangesMap> existing_ranges_;
+ bool vlog_initialized_ = false;
+
static void Reset();
static void DumpHistogramsToVlog(void* instance);
« no previous file with comments | « no previous file | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698