Index: components/metrics/metrics_service.cc |
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc |
index 50545b3f68d2758e7307dac7edd23cb7d08a35e1..98c1456b3c6a934aa365d68a4aa917c6c0b9e77c 100644 |
--- a/components/metrics/metrics_service.cc |
+++ b/components/metrics/metrics_service.cc |
@@ -133,6 +133,7 @@ |
#include "base/location.h" |
#include "base/metrics/histogram_base.h" |
#include "base/metrics/histogram_macros.h" |
+#include "base/metrics/histogram_persistence.h" |
#include "base/metrics/histogram_samples.h" |
#include "base/metrics/sparse_histogram.h" |
#include "base/metrics/statistics_recorder.h" |
@@ -740,6 +741,13 @@ void MetricsService::CloseCurrentLog() { |
OpenNewLog(); // Start trivial log to hold our histograms. |
} |
+ // If a persistent allocator is in use, update its internal histograms (such |
+ // as how much memory is being used) before reporting. |
+ base::PersistentMemoryAllocator* allocator = |
+ base::GetPersistentHistogramMemoryAllocator(); |
+ if (allocator) |
+ allocator->UpdateTrackingHistograms(); |
+ |
// Put incremental data (histogram deltas, and realtime stats deltas) at the |
// end of all log transmissions (initial log handles this separately). |
// RecordIncrementalStabilityElements only exists on the derived |
@@ -1099,13 +1107,19 @@ void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { |
void MetricsService::RecordCurrentHistograms() { |
DCHECK(log_manager_.current_log()); |
+ // "true" indicates that StatisticsRecorder should include histograms in |
+ // persistent storage. |
histogram_snapshot_manager_.PrepareDeltas( |
+ base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), |
base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); |
} |
void MetricsService::RecordCurrentStabilityHistograms() { |
DCHECK(log_manager_.current_log()); |
+ // "true" indicates that StatisticsRecorder should include histograms in |
+ // persistent storage. |
histogram_snapshot_manager_.PrepareDeltas( |
+ base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), |
base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); |
} |