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

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

Issue 2973603002: Remove typically unused local_metadata_ field. (Closed)
Patch Set: Created 3 years, 5 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/histogram_samples.cc ('k') | base/metrics/sample_vector.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sample_map.h" 5 #include "base/metrics/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/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void SampleMapIterator::SkipEmptyBuckets() { 72 void SampleMapIterator::SkipEmptyBuckets() {
73 while (!Done() && iter_->second == 0) { 73 while (!Done() && iter_->second == 0) {
74 ++iter_; 74 ++iter_;
75 } 75 }
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
80 SampleMap::SampleMap() : SampleMap(0) {} 80 SampleMap::SampleMap() : SampleMap(0) {}
81 81
82 SampleMap::SampleMap(uint64_t id) : HistogramSamples(id) {} 82 SampleMap::SampleMap(uint64_t id) : HistogramSamples(id, new LocalMetadata()) {}
83 83
84 SampleMap::~SampleMap() {} 84 SampleMap::~SampleMap() {
85 delete static_cast<LocalMetadata*>(meta());
86 }
85 87
86 void SampleMap::Accumulate(Sample value, Count count) { 88 void SampleMap::Accumulate(Sample value, Count count) {
87 sample_counts_[value] += count; 89 sample_counts_[value] += count;
88 IncreaseSumAndCount(strict_cast<int64_t>(count) * value, count); 90 IncreaseSumAndCount(strict_cast<int64_t>(count) * value, count);
89 } 91 }
90 92
91 Count SampleMap::GetCount(Sample value) const { 93 Count SampleMap::GetCount(Sample value) const {
92 std::map<Sample, Count>::const_iterator it = sample_counts_.find(value); 94 std::map<Sample, Count>::const_iterator it = sample_counts_.find(value);
93 if (it == sample_counts_.end()) 95 if (it == sample_counts_.end())
94 return 0; 96 return 0;
(...skipping 20 matching lines...) Expand all
115 iter->Get(&min, &max, &count); 117 iter->Get(&min, &max, &count);
116 if (strict_cast<int64_t>(min) + 1 != max) 118 if (strict_cast<int64_t>(min) + 1 != max)
117 return false; // SparseHistogram only supports bucket with size 1. 119 return false; // SparseHistogram only supports bucket with size 1.
118 120
119 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count; 121 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count;
120 } 122 }
121 return true; 123 return true;
122 } 124 }
123 125
124 } // namespace base 126 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_samples.cc ('k') | base/metrics/sample_vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698