Index: base/metrics/statistics_recorder.cc |
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc |
index d0fa2add3603b3f574dfa9ef9e5ee2e6b152aafc..2bb50ad3a33da3117475170fbefe152814c3e3e4 100644 |
--- a/base/metrics/statistics_recorder.cc |
+++ b/base/metrics/statistics_recorder.cc |
@@ -67,6 +67,15 @@ StatisticsRecorder::HistogramIterator::operator++() { |
return *this; |
} |
+StatisticsRecorder::~StatisticsRecorder() { |
+ DCHECK(lock_); |
+ DCHECK(histograms_); |
+ DCHECK(ranges_); |
+ |
+ // Global clean up. |
+ Reset(); |
+} |
+ |
// static |
void StatisticsRecorder::Initialize() { |
// Ensure that an instance of the StatisticsRecorder object is created. |
@@ -369,6 +378,17 @@ StatisticsRecorder::OnSampleCallback StatisticsRecorder::FindCallback( |
} |
// static |
+size_t StatisticsRecorder::GetHistogramCount() { |
+ if (!lock_) |
+ return 0; |
+ |
+ base::AutoLock auto_lock(*lock_); |
+ if (!histograms_) |
+ return 0; |
+ return histograms_->size(); |
+} |
+ |
+// static |
void StatisticsRecorder::ResetForTesting() { |
// Just call the private version that is used also by the destructor. |
Reset(); |
@@ -403,13 +423,6 @@ StatisticsRecorder::StatisticsRecorder() { |
AtExitManager::RegisterCallback(&DumpHistogramsToVlog, this); |
} |
-StatisticsRecorder::~StatisticsRecorder() { |
- DCHECK(histograms_ && ranges_ && lock_); |
- |
- // Global clean up. |
- Reset(); |
-} |
- |
// static |
void StatisticsRecorder::Reset() { |
// If there's no lock then there is nothing to reset. |