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

Unified Diff: base/metrics/sparse_histogram.cc

Issue 1471073007: Reorganize histograms for persistence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: addressed review comments by Alexei Created 5 years 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') | base/metrics/statistics_recorder.h » ('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 7955c572811f2c685535f52cdb81f7c94b8955e2..db76a8a9e00911fd3c4c8008530e775d29e2d231 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/metrics/metrics_hashes.h"
#include "base/metrics/sample_map.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
@@ -35,6 +36,10 @@ HistogramBase* SparseHistogram::FactoryGet(const std::string& name,
SparseHistogram::~SparseHistogram() {}
+uint64_t SparseHistogram::name_hash() const {
+ return samples_.id();
+}
+
HistogramType SparseHistogram::GetHistogramType() const {
return SPARSE_HISTOGRAM;
}
@@ -65,7 +70,7 @@ void SparseHistogram::AddCount(Sample value, int count) {
}
scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
- scoped_ptr<SampleMap> snapshot(new SampleMap());
+ scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
base::AutoLock auto_lock(lock_);
snapshot->Add(samples_);
@@ -97,7 +102,8 @@ bool SparseHistogram::SerializeInfoImpl(Pickle* pickle) const {
}
SparseHistogram::SparseHistogram(const std::string& name)
- : HistogramBase(name) {}
+ : HistogramBase(name),
+ samples_(HashMetricName(name)) {}
HistogramBase* SparseHistogram::DeserializeInfoImpl(PickleIterator* iter) {
std::string histogram_name;
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698