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

Unified Diff: base/metrics/sparse_histogram.cc

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed some unnecessary includes Created 4 years, 7 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') | chrome/browser/chrome_browser_field_trials.cc » ('j') | 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 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);
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | chrome/browser/chrome_browser_field_trials.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698