summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/metrics/histogram_base.h4
-rw-r--r--base/metrics/histogram_samples.cc3
-rw-r--r--base/metrics/sample_vector.cc3
3 files changed, 6 insertions, 4 deletions
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h
index f5448e7..dba4395 100644
--- a/base/metrics/histogram_base.h
+++ b/base/metrics/histogram_base.h
@@ -50,8 +50,8 @@ BASE_EXPORT void DeserializeHistogramAndAddSamples(PickleIterator* iter);
class BASE_EXPORT HistogramBase {
public:
- typedef int Sample; // Used for samples.
- typedef int Count; // Used to count samples.
+ typedef int Sample; // Used for samples.
+ typedef subtle::Atomic32 Count; // Used to count samples.
static const Sample kSampleType_MAX; // INT_MAX
diff --git a/base/metrics/histogram_samples.cc b/base/metrics/histogram_samples.cc
index 0e0eeb4..9f3dd6a 100644
--- a/base/metrics/histogram_samples.cc
+++ b/base/metrics/histogram_samples.cc
@@ -113,7 +113,8 @@ void HistogramSamples::IncreaseSum(int64 diff) {
}
void HistogramSamples::IncreaseRedundantCount(HistogramBase::Count diff) {
- redundant_count_ += diff;
+ base::subtle::NoBarrier_Store(&redundant_count_,
+ base::subtle::NoBarrier_Load(&redundant_count_) + diff);
}
SampleCountIterator::~SampleCountIterator() {}
diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc
index fe602ee..89233c7 100644
--- a/base/metrics/sample_vector.cc
+++ b/base/metrics/sample_vector.cc
@@ -24,7 +24,8 @@ SampleVector::~SampleVector() {}
void SampleVector::Accumulate(Sample value, Count count) {
size_t bucket_index = GetBucketIndex(value);
- counts_[bucket_index] += count;
+ subtle::NoBarrier_Store(&counts_[bucket_index],
+ subtle::NoBarrier_Load(&counts_[bucket_index]) + count);
IncreaseSum(count * value);
IncreaseRedundantCount(count);
}