Chromium Code Reviews| Index: base/metrics/sparse_histogram.cc |
| diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc |
| index 7955c572811f2c685535f52cdb81f7c94b8955e2..21697fb9a1bcf8e13e75be75b68fc4f45ceb6c41 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,8 @@ 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(HashMetricName(histogram_name()))); |
|
Alexei Svitkine (slow)
2015/12/09 23:03:40
Pass in name_hash() instead.
bcwhite
2015/12/10 14:51:33
Done.
|
| base::AutoLock auto_lock(lock_); |
| snapshot->Add(samples_); |
| @@ -97,7 +103,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; |