OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/metrics/persistent_sample_map.h" | 5 #include "base/metrics/persistent_sample_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/metrics/persistent_histogram_allocator.h" | 10 #include "base/metrics/persistent_histogram_allocator.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 Metadata* meta) | 108 Metadata* meta) |
109 : HistogramSamples(id, meta), allocator_(allocator) {} | 109 : HistogramSamples(id, meta), allocator_(allocator) {} |
110 | 110 |
111 PersistentSampleMap::~PersistentSampleMap() { | 111 PersistentSampleMap::~PersistentSampleMap() { |
112 if (records_) | 112 if (records_) |
113 records_->Release(this); | 113 records_->Release(this); |
114 } | 114 } |
115 | 115 |
116 void PersistentSampleMap::Accumulate(Sample value, Count count) { | 116 void PersistentSampleMap::Accumulate(Sample value, Count count) { |
117 *GetOrCreateSampleCountStorage(value) += count; | 117 *GetOrCreateSampleCountStorage(value) += count; |
118 IncreaseSumAndCount(static_cast<int64_t>(count) * value, count); | 118 IncreaseSum(static_cast<int64_t>(count) * value); |
| 119 IncreaseRedundantCount(count); |
119 } | 120 } |
120 | 121 |
121 Count PersistentSampleMap::GetCount(Sample value) const { | 122 Count PersistentSampleMap::GetCount(Sample value) const { |
122 // Have to override "const" to make sure all samples have been loaded before | 123 // Have to override "const" to make sure all samples have been loaded before |
123 // being able to know what value to return. | 124 // being able to know what value to return. |
124 Count* count_pointer = | 125 Count* count_pointer = |
125 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value); | 126 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value); |
126 return count_pointer ? *count_pointer : 0; | 127 return count_pointer ? *count_pointer : 0; |
127 } | 128 } |
128 | 129 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 found_count = &record->count; | 312 found_count = &record->count; |
312 if (!import_everything) | 313 if (!import_everything) |
313 break; | 314 break; |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 return found_count; | 318 return found_count; |
318 } | 319 } |
319 | 320 |
320 } // namespace base | 321 } // namespace base |
OLD | NEW |