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

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

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 7 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 (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/sparse_histogram.h" 5 #include "base/metrics/sparse_histogram.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/metrics_hashes.h" 10 #include "base/metrics/metrics_hashes.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 uint64_t SparseHistogram::name_hash() const { 87 uint64_t SparseHistogram::name_hash() const {
88 return samples_->id(); 88 return samples_->id();
89 } 89 }
90 90
91 HistogramType SparseHistogram::GetHistogramType() const { 91 HistogramType SparseHistogram::GetHistogramType() const {
92 return SPARSE_HISTOGRAM; 92 return SPARSE_HISTOGRAM;
93 } 93 }
94 94
95 bool SparseHistogram::HasConstructionArguments( 95 bool SparseHistogram::HasConstructionArguments(
96 Sample expected_minimum, 96 Sample /*expected_minimum*/,
97 Sample expected_maximum, 97 Sample /*expected_maximum*/,
98 uint32_t expected_bucket_count) const { 98 uint32_t /*expected_bucket_count*/) const {
99 // SparseHistogram never has min/max/bucket_count limit. 99 // SparseHistogram never has min/max/bucket_count limit.
100 return false; 100 return false;
101 } 101 }
102 102
103 void SparseHistogram::Add(Sample value) { 103 void SparseHistogram::Add(Sample value) {
104 AddCount(value, 1); 104 AddCount(value, 1);
105 } 105 }
106 106
107 void SparseHistogram::AddCount(Sample value, int count) { 107 void SparseHistogram::AddCount(Sample value, int count) {
108 if (count <= 0) { 108 if (count <= 0) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DLOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name; 207 DLOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name;
208 return NULL; 208 return NULL;
209 } 209 }
210 210
211 DCHECK(flags & HistogramBase::kIPCSerializationSourceFlag); 211 DCHECK(flags & HistogramBase::kIPCSerializationSourceFlag);
212 flags &= ~HistogramBase::kIPCSerializationSourceFlag; 212 flags &= ~HistogramBase::kIPCSerializationSourceFlag;
213 213
214 return SparseHistogram::FactoryGet(histogram_name, flags); 214 return SparseHistogram::FactoryGet(histogram_name, flags);
215 } 215 }
216 216
217 void SparseHistogram::GetParameters(DictionaryValue* params) const { 217 void SparseHistogram::GetParameters(DictionaryValue* /*params*/) const {
218 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 218 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
219 } 219 }
220 220
221 void SparseHistogram::GetCountAndBucketData(Count* count, 221 void SparseHistogram::GetCountAndBucketData(Count* /*count*/,
222 int64_t* sum, 222 int64_t* /*sum*/,
223 ListValue* buckets) const { 223 ListValue* /*buckets*/) const {
224 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 224 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
225 } 225 }
226 226
227 void SparseHistogram::WriteAsciiImpl(bool graph_it, 227 void SparseHistogram::WriteAsciiImpl(bool graph_it,
228 const std::string& newline, 228 const std::string& newline,
229 std::string* output) const { 229 std::string* output) const {
230 // Get a local copy of the data so we are consistent. 230 // Get a local copy of the data so we are consistent.
231 std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples(); 231 std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples();
232 Count total_count = snapshot->TotalCount(); 232 Count total_count = snapshot->TotalCount();
233 double scaled_total_count = total_count / 100.0; 233 double scaled_total_count = total_count / 100.0;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 std::string* output) const { 281 std::string* output) const {
282 StringAppendF(output, 282 StringAppendF(output,
283 "Histogram: %s recorded %d samples", 283 "Histogram: %s recorded %d samples",
284 histogram_name().c_str(), 284 histogram_name().c_str(),
285 total_count); 285 total_count);
286 if (flags() & ~kHexRangePrintingFlag) 286 if (flags() & ~kHexRangePrintingFlag)
287 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); 287 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag);
288 } 288 }
289 289
290 } // namespace base 290 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698