Index: base/metrics/sparse_histogram.cc |
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc |
index e2bf4bfed18a949d8a95177287f9c432541c731a..a2dbb61b218b9b42b90543547c344fb42d26b5cc 100644 |
--- a/base/metrics/sparse_histogram.cc |
+++ b/base/metrics/sparse_histogram.cc |
@@ -126,6 +126,8 @@ std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
} |
std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() { |
+ DCHECK(!final_delta_created_); |
+ |
std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
base::AutoLock auto_lock(lock_); |
snapshot->Add(*samples_); |
@@ -136,6 +138,19 @@ std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() { |
return std::move(snapshot); |
} |
+std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotFinalDelta() const { |
+ DCHECK(!final_delta_created_); |
+ final_delta_created_ = true; |
+ |
+ std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
+ base::AutoLock auto_lock(lock_); |
+ snapshot->Add(*samples_); |
+ |
+ // Subtract what was previously logged and then return. |
+ snapshot->Subtract(*logged_samples_); |
+ return std::move(snapshot); |
+} |
+ |
void SparseHistogram::AddSamples(const HistogramSamples& samples) { |
base::AutoLock auto_lock(lock_); |
samples_->Add(samples); |