Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: base/metrics/persistent_sample_map.cc

Issue 2832333002: Revert of Embed a single sample in histogram metadata. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/sample_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/sample_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698