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

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

Issue 2811713003: Embed a single sample in histogram metadata. (Closed)
Patch Set: fixed build problems 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
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 IncreaseSum(static_cast<int64_t>(count) * value); 118 IncreaseSumAndCount(static_cast<int64_t>(count) * value, count);
119 IncreaseRedundantCount(count);
120 } 119 }
121 120
122 Count PersistentSampleMap::GetCount(Sample value) const { 121 Count PersistentSampleMap::GetCount(Sample value) const {
123 // Have to override "const" to make sure all samples have been loaded before 122 // Have to override "const" to make sure all samples have been loaded before
124 // being able to know what value to return. 123 // being able to know what value to return.
125 Count* count_pointer = 124 Count* count_pointer =
126 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value); 125 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value);
127 return count_pointer ? *count_pointer : 0; 126 return count_pointer ? *count_pointer : 0;
128 } 127 }
129 128
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 found_count = &record->count; 311 found_count = &record->count;
313 if (!import_everything) 312 if (!import_everything)
314 break; 313 break;
315 } 314 }
316 } 315 }
317 316
318 return found_count; 317 return found_count;
319 } 318 }
320 319
321 } // namespace base 320 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698