| Index: base/metrics/persistent_sample_map.cc
|
| diff --git a/base/metrics/persistent_sample_map.cc b/base/metrics/persistent_sample_map.cc
|
| index 743b64401cfa97741725ef2cf99aeeee6d2fe59e..af09f97702ea86f7371deb7b8a18e47fbeaca471 100644
|
| --- a/base/metrics/persistent_sample_map.cc
|
| +++ b/base/metrics/persistent_sample_map.cc
|
| @@ -24,6 +24,9 @@ enum NegativeSampleReason {
|
| PERSISTENT_SPARSE_ADDED_NEGATIVE_COUNT,
|
| PERSISTENT_SPARSE_ADD_WENT_NEGATIVE,
|
| PERSISTENT_SPARSE_ADD_OVERFLOW,
|
| + PERSISTENT_SPARSE_ACCUMULATE_NEGATIVE_COUNT,
|
| + PERSISTENT_SPARSE_ACCUMULATE_WENT_NEGATIVE,
|
| + PERSISTENT_SPARSE_ACCUMULATE_OVERFLOW,
|
| MAX_NEGATIVE_SAMPLE_REASONS
|
| };
|
|
|
| @@ -118,7 +121,26 @@ PersistentSampleMap::~PersistentSampleMap() {
|
| }
|
|
|
| void PersistentSampleMap::Accumulate(Sample value, Count count) {
|
| +#if 0 // TODO(bcwhite) Re-enable efficient version after crbug.com/682680.
|
| *GetOrCreateSampleCountStorage(value) += count;
|
| +#else
|
| + NegativeSampleReason reason = MAX_NEGATIVE_SAMPLE_REASONS;
|
| + Count* local_count_ptr = GetOrCreateSampleCountStorage(value);
|
| + if (count < 0) {
|
| + reason = PERSISTENT_SPARSE_ACCUMULATE_NEGATIVE_COUNT;
|
| + if (*local_count_ptr < -count)
|
| + reason = PERSISTENT_SPARSE_ACCUMULATE_WENT_NEGATIVE;
|
| + *local_count_ptr += count;
|
| + } else {
|
| + *local_count_ptr += count;
|
| + if (*local_count_ptr < 0)
|
| + reason = PERSISTENT_SPARSE_ACCUMULATE_OVERFLOW;
|
| + }
|
| + if (reason != MAX_NEGATIVE_SAMPLE_REASONS) {
|
| + UMA_HISTOGRAM_ENUMERATION("UMA.NegativeSamples.Reason", reason,
|
| + MAX_NEGATIVE_SAMPLE_REASONS);
|
| + }
|
| +#endif
|
| IncreaseSumAndCount(strict_cast<int64_t>(count) * value, count);
|
| }
|
|
|
| @@ -195,48 +217,8 @@ bool PersistentSampleMap::AddSubtractImpl(SampleCountIterator* iter,
|
| continue;
|
| if (strict_cast<int64_t>(min) + 1 != max)
|
| return false; // SparseHistogram only supports bucket with size 1.
|
| -
|
| -#if 0 // TODO(bcwhite) Re-enable efficient version after crbug.com/682680.
|
| *GetOrCreateSampleCountStorage(min) +=
|
| (op == HistogramSamples::ADD) ? count : -count;
|
| -#else
|
| - NegativeSampleReason reason = MAX_NEGATIVE_SAMPLE_REASONS;
|
| - if (op == HistogramSamples::ADD) {
|
| - // Add should generally be adding only positive values.
|
| - Count* local_count_ptr = GetOrCreateSampleCountStorage(min);
|
| - if (count < 0) {
|
| - reason = PERSISTENT_SPARSE_ADDED_NEGATIVE_COUNT;
|
| - if (*local_count_ptr < -count) {
|
| - reason = PERSISTENT_SPARSE_ADD_WENT_NEGATIVE;
|
| - *local_count_ptr = 0;
|
| - }
|
| - } else {
|
| - *local_count_ptr += count;
|
| - if (*local_count_ptr < 0)
|
| - reason = PERSISTENT_SPARSE_ADD_OVERFLOW;
|
| - }
|
| - } else {
|
| - // Subtract is used only for determining deltas when reporting which
|
| - // means that it's in the "logged" iterator. It should have an active
|
| - // sample record and thus there is no need to try to create one.
|
| - Count* local_count_ptr = GetSampleCountStorage(min);
|
| - if (local_count_ptr == nullptr) {
|
| - reason = PERSISTENT_SPARSE_HAVE_LOGGED_BUT_NOT_SAMPLE;
|
| - } else {
|
| - if (*local_count_ptr < count) {
|
| - reason = PERSISTENT_SPARSE_SAMPLE_LESS_THAN_LOGGED;
|
| - *local_count_ptr = 0;
|
| - } else {
|
| - *local_count_ptr -= count;
|
| - }
|
| - }
|
| - }
|
| - if (reason != MAX_NEGATIVE_SAMPLE_REASONS) {
|
| - NOTREACHED();
|
| - UMA_HISTOGRAM_ENUMERATION("UMA.NegativeSamples.Reason", reason,
|
| - MAX_NEGATIVE_SAMPLE_REASONS);
|
| - }
|
| -#endif
|
| }
|
| return true;
|
| }
|
|
|