| Index: base/metrics/sample_map.cc
|
| diff --git a/base/metrics/sample_map.cc b/base/metrics/sample_map.cc
|
| index 5ef0fb87ab604d23a5bdb203e774247c69c62257..f0e4e5edb15b089394dfa95fe57ce106ca9d5266 100644
|
| --- a/base/metrics/sample_map.cc
|
| +++ b/base/metrics/sample_map.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/numerics/safe_conversions.h"
|
| #include "base/stl_util.h"
|
|
|
| namespace base {
|
| @@ -30,7 +31,7 @@ class SampleMapIterator : public SampleCountIterator {
|
| bool Done() const override;
|
| void Next() override;
|
| void Get(HistogramBase::Sample* min,
|
| - HistogramBase::Sample* max,
|
| + int64_t* max,
|
| HistogramBase::Count* count) const override;
|
|
|
| private:
|
| @@ -58,12 +59,12 @@ void SampleMapIterator::Next() {
|
| SkipEmptyBuckets();
|
| }
|
|
|
| -void SampleMapIterator::Get(Sample* min, Sample* max, Count* count) const {
|
| +void SampleMapIterator::Get(Sample* min, int64_t* max, Count* count) const {
|
| DCHECK(!Done());
|
| if (min)
|
| *min = iter_->first;
|
| if (max)
|
| - *max = iter_->first + 1;
|
| + *max = strict_cast<int64_t>(iter_->first) + 1;
|
| if (count)
|
| *count = iter_->second;
|
| }
|
| @@ -84,7 +85,7 @@ SampleMap::~SampleMap() {}
|
|
|
| void SampleMap::Accumulate(Sample value, Count count) {
|
| sample_counts_[value] += count;
|
| - IncreaseSumAndCount(static_cast<int64_t>(count) * value, count);
|
| + IncreaseSumAndCount(strict_cast<int64_t>(count) * value, count);
|
| }
|
|
|
| Count SampleMap::GetCount(Sample value) const {
|
| @@ -108,11 +109,11 @@ std::unique_ptr<SampleCountIterator> SampleMap::Iterator() const {
|
|
|
| bool SampleMap::AddSubtractImpl(SampleCountIterator* iter, Operator op) {
|
| Sample min;
|
| - Sample max;
|
| + int64_t max;
|
| Count count;
|
| for (; !iter->Done(); iter->Next()) {
|
| iter->Get(&min, &max, &count);
|
| - if (min + 1 != max)
|
| + if (strict_cast<int64_t>(min) + 1 != max)
|
| return false; // SparseHistogram only supports bucket with size 1.
|
|
|
| sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count;
|
|
|