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

Unified Diff: base/metrics/sparse_histogram.cc

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: addressed remaining review comments by Alexei Created 4 years, 10 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/sparse_histogram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram.cc
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index 5282aa6b2c38600a0fbe61a58ab46015ee47ff02..5653456a29fb552470871f8611cb6337ec65bc50 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -77,6 +77,17 @@ scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
return std::move(snapshot);
}
+scoped_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
+ scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
+ base::AutoLock auto_lock(lock_);
+ snapshot->Add(samples_);
+
+ // Subtract what was previously logged and update that information.
+ snapshot->Subtract(logged_samples_);
+ logged_samples_.Add(*snapshot);
+ return std::move(snapshot);
+}
+
void SparseHistogram::AddSamples(const HistogramSamples& samples) {
base::AutoLock auto_lock(lock_);
samples_.Add(samples);
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698