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

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

Issue 11342060: Histogram type support in HistogramBase and remove SetRangeDescription function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 10 matching lines...) Expand all
21 #include "base/metrics/statistics_recorder.h" 21 #include "base/metrics/statistics_recorder.h"
22 #include "base/pickle.h" 22 #include "base/pickle.h"
23 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/stringprintf.h" 24 #include "base/stringprintf.h"
25 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 27
28 using std::string; 28 using std::string;
29 using std::vector; 29 using std::vector;
30 30
31 namespace {
32
33 std::string ClassTypeToString(base::Histogram::ClassType type) {
34 switch(type) {
35 case base::Histogram::HISTOGRAM:
36 return "HISTOGRAM";
37 break;
38 case base::Histogram::LINEAR_HISTOGRAM:
39 return "LINEAR_HISTOGRAM";
40 break;
41 case base::Histogram::BOOLEAN_HISTOGRAM:
42 return "BOOLEAN_HISTOGRAM";
43 break;
44 case base::Histogram::CUSTOM_HISTOGRAM:
45 return "CUSTOM_HISTOGRAM";
46 break;
47 default:
48 NOTREACHED();
49 break;
50 }
51 return "UNKNOWN";
52 }
53
54 } // namespace
55
56 namespace base { 31 namespace base {
57 32
58 typedef HistogramBase::Count Count; 33 typedef HistogramBase::Count Count;
59 typedef HistogramBase::Sample Sample; 34 typedef HistogramBase::Sample Sample;
60 35
61 // static 36 // static
62 const size_t Histogram::kBucketCount_MAX = 16384u; 37 const size_t Histogram::kBucketCount_MAX = 16384u;
63 38
64 // TODO(rtenneti): delete this code after debugging. 39 // TODO(rtenneti): delete this code after debugging.
65 void CheckCorruption(const Histogram& histogram, bool new_histogram) { 40 void CheckCorruption(const Histogram& histogram, bool new_histogram) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 new Histogram(name, minimum, maximum, bucket_count, registered_ranges); 80 new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
106 CheckCorruption(*tentative_histogram, true); 81 CheckCorruption(*tentative_histogram, true);
107 82
108 tentative_histogram->SetFlags(flags); 83 tentative_histogram->SetFlags(flags);
109 histogram = 84 histogram =
110 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 85 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
111 } 86 }
112 // TODO(rtenneti): delete this code after debugging. 87 // TODO(rtenneti): delete this code after debugging.
113 CheckCorruption(*histogram, false); 88 CheckCorruption(*histogram, false);
114 89
115 CHECK_EQ(HISTOGRAM, histogram->histogram_type()); 90 CHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
116 CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); 91 CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
117 return histogram; 92 return histogram;
118 } 93 }
119 94
120 Histogram* Histogram::FactoryTimeGet(const string& name, 95 Histogram* Histogram::FactoryTimeGet(const string& name,
121 TimeDelta minimum, 96 TimeDelta minimum,
122 TimeDelta maximum, 97 TimeDelta maximum,
123 size_t bucket_count, 98 size_t bucket_count,
124 int32 flags) { 99 int32 flags) {
125 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), 100 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 154 }
180 155
181 void Histogram::AddSamples(const HistogramSamples& samples) { 156 void Histogram::AddSamples(const HistogramSamples& samples) {
182 samples_->Add(samples); 157 samples_->Add(samples);
183 } 158 }
184 159
185 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { 160 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) {
186 return samples_->AddFromPickle(iter); 161 return samples_->AddFromPickle(iter);
187 } 162 }
188 163
189 void Histogram::SetRangeDescriptions(const DescriptionPair descriptions[]) {
190 DCHECK(false);
191 }
192
193 // static 164 // static
194 string Histogram::SerializeHistogramInfo(const Histogram& histogram, 165 string Histogram::SerializeHistogramInfo(const Histogram& histogram,
195 const HistogramSamples& snapshot) { 166 const HistogramSamples& snapshot) {
196 DCHECK_NE(NOT_VALID_IN_RENDERER, histogram.histogram_type());
Ilya Sherman 2012/10/31 00:35:19 Please double-check with Jim that this is ok to re
197 DCHECK(histogram.bucket_ranges()->HasValidChecksum()); 167 DCHECK(histogram.bucket_ranges()->HasValidChecksum());
198 168
199 Pickle pickle; 169 Pickle pickle;
200 pickle.WriteString(histogram.histogram_name()); 170 pickle.WriteString(histogram.histogram_name());
201 pickle.WriteInt(histogram.declared_min()); 171 pickle.WriteInt(histogram.declared_min());
202 pickle.WriteInt(histogram.declared_max()); 172 pickle.WriteInt(histogram.declared_max());
203 pickle.WriteUInt64(histogram.bucket_count()); 173 pickle.WriteUInt64(histogram.bucket_count());
204 pickle.WriteUInt32(histogram.bucket_ranges()->checksum()); 174 pickle.WriteUInt32(histogram.bucket_ranges()->checksum());
205 pickle.WriteInt(histogram.histogram_type()); 175 pickle.WriteInt(histogram.GetHistogramType());
206 pickle.WriteInt(histogram.flags()); 176 pickle.WriteInt(histogram.flags());
207 177
208 histogram.SerializeRanges(&pickle); 178 histogram.SerializeRanges(&pickle);
209 179
210 snapshot.Serialize(&pickle); 180 snapshot.Serialize(&pickle);
211 181
212 return string(static_cast<const char*>(pickle.data()), pickle.size()); 182 return string(static_cast<const char*>(pickle.data()), pickle.size());
213 } 183 }
214 184
215 // static 185 // static
(...skipping 28 matching lines...) Expand all
244 // Since these fields may have come from an untrusted renderer, do additional 214 // Since these fields may have come from an untrusted renderer, do additional
245 // checks above and beyond those in Histogram::Initialize() 215 // checks above and beyond those in Histogram::Initialize()
246 if (declared_max <= 0 || declared_min <= 0 || declared_max < declared_min || 216 if (declared_max <= 0 || declared_min <= 0 || declared_max < declared_min ||
247 INT_MAX / sizeof(Count) <= bucket_count || bucket_count < 2) { 217 INT_MAX / sizeof(Count) <= bucket_count || bucket_count < 2) {
248 DLOG(ERROR) << "Values error decoding Histogram: " << histogram_name; 218 DLOG(ERROR) << "Values error decoding Histogram: " << histogram_name;
249 return false; 219 return false;
250 } 220 }
251 221
252 Flags flags = static_cast<Flags>(pickle_flags & ~kIPCSerializationSourceFlag); 222 Flags flags = static_cast<Flags>(pickle_flags & ~kIPCSerializationSourceFlag);
253 223
254 DCHECK_NE(NOT_VALID_IN_RENDERER, histogram_type);
255
256 Histogram* render_histogram(NULL); 224 Histogram* render_histogram(NULL);
257 225
258 if (histogram_type == HISTOGRAM) { 226 if (histogram_type == HISTOGRAM) {
259 render_histogram = Histogram::FactoryGet( 227 render_histogram = Histogram::FactoryGet(
260 histogram_name, declared_min, declared_max, bucket_count, flags); 228 histogram_name, declared_min, declared_max, bucket_count, flags);
261 } else if (histogram_type == LINEAR_HISTOGRAM) { 229 } else if (histogram_type == LINEAR_HISTOGRAM) {
262 render_histogram = LinearHistogram::FactoryGet( 230 render_histogram = LinearHistogram::FactoryGet(
263 histogram_name, declared_min, declared_max, bucket_count, flags); 231 histogram_name, declared_min, declared_max, bucket_count, flags);
264 } else if (histogram_type == BOOLEAN_HISTOGRAM) { 232 } else if (histogram_type == BOOLEAN_HISTOGRAM) {
265 render_histogram = BooleanHistogram::FactoryGet(histogram_name, flags); 233 render_histogram = BooleanHistogram::FactoryGet(histogram_name, flags);
266 } else if (histogram_type == CUSTOM_HISTOGRAM) { 234 } else if (histogram_type == CUSTOM_HISTOGRAM) {
267 vector<Sample> sample_ranges(bucket_count); 235 vector<Sample> sample_ranges(bucket_count);
268 if (!CustomHistogram::DeserializeRanges(&iter, &sample_ranges)) { 236 if (!CustomHistogram::DeserializeRanges(&iter, &sample_ranges)) {
269 DLOG(ERROR) << "Pickle error decoding ranges: " << histogram_name; 237 DLOG(ERROR) << "Pickle error decoding ranges: " << histogram_name;
270 return false; 238 return false;
271 } 239 }
272 render_histogram = 240 render_histogram =
273 CustomHistogram::FactoryGet(histogram_name, sample_ranges, flags); 241 CustomHistogram::FactoryGet(histogram_name, sample_ranges, flags);
274 } else { 242 } else {
275 DLOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " 243 DLOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: "
276 << histogram_type; 244 << histogram_type;
277 return false; 245 return false;
278 } 246 }
279 247
280 DCHECK_EQ(render_histogram->declared_min(), declared_min); 248 DCHECK_EQ(render_histogram->declared_min(), declared_min);
281 DCHECK_EQ(render_histogram->declared_max(), declared_max); 249 DCHECK_EQ(render_histogram->declared_max(), declared_max);
282 DCHECK_EQ(render_histogram->bucket_count(), bucket_count); 250 DCHECK_EQ(render_histogram->bucket_count(), bucket_count);
283 DCHECK_EQ(render_histogram->histogram_type(), histogram_type); 251 DCHECK_EQ(render_histogram->GetHistogramType(), histogram_type);
284 252
285 if (render_histogram->bucket_ranges()->checksum() != range_checksum) { 253 if (render_histogram->bucket_ranges()->checksum() != range_checksum) {
286 return false; 254 return false;
287 } 255 }
288 256
289 if (render_histogram->flags() & kIPCSerializationSourceFlag) { 257 if (render_histogram->flags() & kIPCSerializationSourceFlag) {
290 DVLOG(1) << "Single process mode, histogram observed and not copied: " 258 DVLOG(1) << "Single process mode, histogram observed and not copied: "
291 << histogram_name; 259 << histogram_name;
292 return true; 260 return true;
293 } 261 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } else { 293 } else {
326 DCHECK_GT(0, delta); 294 DCHECK_GT(0, delta);
327 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentCountLow", -delta); 295 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentCountLow", -delta);
328 if (-delta > kCommonRaceBasedCountMismatch) 296 if (-delta > kCommonRaceBasedCountMismatch)
329 inconsistencies |= COUNT_LOW_ERROR; 297 inconsistencies |= COUNT_LOW_ERROR;
330 } 298 }
331 } 299 }
332 return static_cast<Inconsistencies>(inconsistencies); 300 return static_cast<Inconsistencies>(inconsistencies);
333 } 301 }
334 302
335 Histogram::ClassType Histogram::histogram_type() const {
336 return HISTOGRAM;
337 }
338
339 Sample Histogram::ranges(size_t i) const { 303 Sample Histogram::ranges(size_t i) const {
340 return bucket_ranges_->range(i); 304 return bucket_ranges_->range(i);
341 } 305 }
342 306
343 size_t Histogram::bucket_count() const { 307 size_t Histogram::bucket_count() const {
344 return bucket_count_; 308 return bucket_count_;
345 } 309 }
346 310
347 // static 311 // static
348 bool Histogram::InspectConstructionArguments(const string& name, 312 bool Histogram::InspectConstructionArguments(const string& name,
(...skipping 17 matching lines...) Expand all
366 330
367 if (*minimum >= *maximum) 331 if (*minimum >= *maximum)
368 return false; 332 return false;
369 if (*bucket_count < 3) 333 if (*bucket_count < 3)
370 return false; 334 return false;
371 if (*bucket_count > static_cast<size_t>(*maximum - *minimum + 2)) 335 if (*bucket_count > static_cast<size_t>(*maximum - *minimum + 2))
372 return false; 336 return false;
373 return true; 337 return true;
374 } 338 }
375 339
340 HistogramType Histogram::GetHistogramType() const {
341 return HISTOGRAM;
342 }
343
376 bool Histogram::HasConstructionArguments(Sample minimum, 344 bool Histogram::HasConstructionArguments(Sample minimum,
377 Sample maximum, 345 Sample maximum,
378 size_t bucket_count) const { 346 size_t bucket_count) const {
379 return ((minimum == declared_min_) && (maximum == declared_max_) && 347 return ((minimum == declared_min_) && (maximum == declared_max_) &&
380 (bucket_count == bucket_count_)); 348 (bucket_count == bucket_count_));
381 } 349 }
382 350
383 void Histogram::Add(int value) { 351 void Histogram::Add(int value) {
384 DCHECK_EQ(0, ranges(0)); 352 DCHECK_EQ(0, ranges(0));
385 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count_)); 353 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count_));
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 int x_remainder = k_line_length - x_count; 560 int x_remainder = k_line_length - x_count;
593 561
594 while (0 < x_count--) 562 while (0 < x_count--)
595 output->append("-"); 563 output->append("-");
596 output->append("O"); 564 output->append("O");
597 while (0 < x_remainder--) 565 while (0 < x_remainder--)
598 output->append(" "); 566 output->append(" ");
599 } 567 }
600 568
601 void Histogram::GetParameters(DictionaryValue* params) const { 569 void Histogram::GetParameters(DictionaryValue* params) const {
602 params->SetString("type", ClassTypeToString(histogram_type())); 570 params->SetString("type", HistogramTypeName(GetHistogramType()));
603 params->SetInteger("min", declared_min()); 571 params->SetInteger("min", declared_min());
604 params->SetInteger("max", declared_max()); 572 params->SetInteger("max", declared_max());
605 params->SetInteger("bucket_count", static_cast<int>(bucket_count())); 573 params->SetInteger("bucket_count", static_cast<int>(bucket_count()));
606 } 574 }
607 575
608 void Histogram::GetCountAndBucketData(Count* count, ListValue* buckets) const { 576 void Histogram::GetCountAndBucketData(Count* count, ListValue* buckets) const {
609 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); 577 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector();
610 *count = snapshot->TotalCount(); 578 *count = snapshot->TotalCount();
611 size_t index = 0; 579 size_t index = 0;
612 for (size_t i = 0; i < bucket_count(); ++i) { 580 for (size_t i = 0; i < bucket_count(); ++i) {
(...skipping 15 matching lines...) Expand all
628 // buckets. 596 // buckets.
629 //------------------------------------------------------------------------------ 597 //------------------------------------------------------------------------------
630 598
631 LinearHistogram::~LinearHistogram() {} 599 LinearHistogram::~LinearHistogram() {}
632 600
633 Histogram* LinearHistogram::FactoryGet(const string& name, 601 Histogram* LinearHistogram::FactoryGet(const string& name,
634 Sample minimum, 602 Sample minimum,
635 Sample maximum, 603 Sample maximum,
636 size_t bucket_count, 604 size_t bucket_count,
637 int32 flags) { 605 int32 flags) {
606 return FactoryGetWithRangeDescription(
607 name, minimum, maximum, bucket_count, flags, NULL);
608 }
609
610 Histogram* LinearHistogram::FactoryTimeGet(const string& name,
611 TimeDelta minimum,
612 TimeDelta maximum,
613 size_t bucket_count,
614 int32 flags) {
615 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(),
616 bucket_count, flags);
617 }
618
619 Histogram* LinearHistogram::FactoryGetWithRangeDescription(
620 const std::string& name,
621 Sample minimum,
622 Sample maximum,
623 size_t bucket_count,
624 int32 flags,
625 const DescriptionPair descriptions[]) {
638 bool valid_arguments = Histogram::InspectConstructionArguments( 626 bool valid_arguments = Histogram::InspectConstructionArguments(
639 name, &minimum, &maximum, &bucket_count); 627 name, &minimum, &maximum, &bucket_count);
640 DCHECK(valid_arguments); 628 DCHECK(valid_arguments);
641 629
642 Histogram* histogram = StatisticsRecorder::FindHistogram(name); 630 Histogram* histogram = StatisticsRecorder::FindHistogram(name);
643 if (!histogram) { 631 if (!histogram) {
644 // To avoid racy destruction at shutdown, the following will be leaked. 632 // To avoid racy destruction at shutdown, the following will be leaked.
645 BucketRanges* ranges = new BucketRanges(bucket_count + 1); 633 BucketRanges* ranges = new BucketRanges(bucket_count + 1);
646 InitializeBucketRanges(minimum, maximum, bucket_count, ranges); 634 InitializeBucketRanges(minimum, maximum, bucket_count, ranges);
647 const BucketRanges* registered_ranges = 635 const BucketRanges* registered_ranges =
648 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); 636 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges);
649 637
650 LinearHistogram* tentative_histogram = 638 LinearHistogram* tentative_histogram =
651 new LinearHistogram(name, minimum, maximum, bucket_count, 639 new LinearHistogram(name, minimum, maximum, bucket_count,
652 registered_ranges); 640 registered_ranges);
653 CheckCorruption(*tentative_histogram, true); 641 CheckCorruption(*tentative_histogram, true);
654 642
643 // Set range descriptions.
644 if (descriptions != NULL) {
Ilya Sherman 2012/10/31 00:35:19 nit: This is usually written as "if (descriptions)
kaiwang 2012/10/31 01:12:56 Done.
645 for (int i =0; descriptions[i].description; ++i) {
Ilya Sherman 2012/10/31 00:35:19 nit: "=0" -> "= 0"
kaiwang 2012/10/31 01:12:56 Done.
646 tentative_histogram->bucket_description_[descriptions[i].sample] =
647 descriptions[i].description;
648 }
649 }
650
655 tentative_histogram->SetFlags(flags); 651 tentative_histogram->SetFlags(flags);
656 histogram = 652 histogram =
657 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 653 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
658 } 654 }
659 // TODO(rtenneti): delete this code after debugging. 655 // TODO(rtenneti): delete this code after debugging.
660 CheckCorruption(*histogram, false); 656 CheckCorruption(*histogram, false);
661 657
662 CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); 658 CHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
663 CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); 659 CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
664 return histogram; 660 return histogram;
665 } 661 }
666 662
667 Histogram* LinearHistogram::FactoryTimeGet(const string& name, 663 HistogramType LinearHistogram::GetHistogramType() const {
668 TimeDelta minimum,
669 TimeDelta maximum,
670 size_t bucket_count,
671 int32 flags) {
672 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(),
673 bucket_count, flags);
674 }
675
676 Histogram::ClassType LinearHistogram::histogram_type() const {
677 return LINEAR_HISTOGRAM; 664 return LINEAR_HISTOGRAM;
678 } 665 }
679 666
680 void LinearHistogram::SetRangeDescriptions(
681 const DescriptionPair descriptions[]) {
682 for (int i =0; descriptions[i].description; ++i) {
683 bucket_description_[descriptions[i].sample] = descriptions[i].description;
684 }
685 }
686
687 LinearHistogram::LinearHistogram(const string& name, 667 LinearHistogram::LinearHistogram(const string& name,
688 Sample minimum, 668 Sample minimum,
689 Sample maximum, 669 Sample maximum,
690 size_t bucket_count, 670 size_t bucket_count,
691 const BucketRanges* ranges) 671 const BucketRanges* ranges)
692 : Histogram(name, minimum, maximum, bucket_count, ranges) { 672 : Histogram(name, minimum, maximum, bucket_count, ranges) {
693 } 673 }
694 674
695 double LinearHistogram::GetBucketSize(Count current, size_t i) const { 675 double LinearHistogram::GetBucketSize(Count current, size_t i) const {
696 DCHECK_GT(ranges(i + 1), ranges(i)); 676 DCHECK_GT(ranges(i + 1), ranges(i));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 new BooleanHistogram(name, registered_ranges); 727 new BooleanHistogram(name, registered_ranges);
748 CheckCorruption(*tentative_histogram, true); 728 CheckCorruption(*tentative_histogram, true);
749 729
750 tentative_histogram->SetFlags(flags); 730 tentative_histogram->SetFlags(flags);
751 histogram = 731 histogram =
752 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 732 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
753 } 733 }
754 // TODO(rtenneti): delete this code after debugging. 734 // TODO(rtenneti): delete this code after debugging.
755 CheckCorruption(*histogram, false); 735 CheckCorruption(*histogram, false);
756 736
757 CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type()); 737 CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
758 return histogram; 738 return histogram;
759 } 739 }
760 740
761 Histogram::ClassType BooleanHistogram::histogram_type() const { 741 HistogramType BooleanHistogram::GetHistogramType() const {
762 return BOOLEAN_HISTOGRAM; 742 return BOOLEAN_HISTOGRAM;
763 } 743 }
764 744
765 void BooleanHistogram::AddBoolean(bool value) { 745 void BooleanHistogram::AddBoolean(bool value) {
766 Add(value ? 1 : 0); 746 Add(value ? 1 : 0);
767 } 747 }
768 748
769 BooleanHistogram::BooleanHistogram(const string& name, 749 BooleanHistogram::BooleanHistogram(const string& name,
770 const BucketRanges* ranges) 750 const BucketRanges* ranges)
771 : LinearHistogram(name, 1, 2, 3, ranges) {} 751 : LinearHistogram(name, 1, 2, 3, ranges) {}
(...skipping 19 matching lines...) Expand all
791 CheckCorruption(*tentative_histogram, true); 771 CheckCorruption(*tentative_histogram, true);
792 772
793 tentative_histogram->SetFlags(flags); 773 tentative_histogram->SetFlags(flags);
794 774
795 histogram = 775 histogram =
796 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 776 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
797 } 777 }
798 // TODO(rtenneti): delete this code after debugging. 778 // TODO(rtenneti): delete this code after debugging.
799 CheckCorruption(*histogram, false); 779 CheckCorruption(*histogram, false);
800 780
801 CHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); 781 CHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
802 return histogram; 782 return histogram;
803 } 783 }
804 784
805 Histogram::ClassType CustomHistogram::histogram_type() const { 785 HistogramType CustomHistogram::GetHistogramType() const {
806 return CUSTOM_HISTOGRAM; 786 return CUSTOM_HISTOGRAM;
807 } 787 }
808 788
809 // static 789 // static
810 vector<Sample> CustomHistogram::ArrayToCustomRanges( 790 vector<Sample> CustomHistogram::ArrayToCustomRanges(
811 const Sample* values, size_t num_values) { 791 const Sample* values, size_t num_values) {
812 vector<Sample> all_values; 792 vector<Sample> all_values;
813 for (size_t i = 0; i < num_values; ++i) { 793 for (size_t i = 0; i < num_values; ++i) {
814 Sample value = values[i]; 794 Sample value = values[i];
815 all_values.push_back(value); 795 all_values.push_back(value);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 857
878 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); 858 BucketRanges* bucket_ranges = new BucketRanges(ranges.size());
879 for (size_t i = 0; i < ranges.size(); i++) { 859 for (size_t i = 0; i < ranges.size(); i++) {
880 bucket_ranges->set_range(i, ranges[i]); 860 bucket_ranges->set_range(i, ranges[i]);
881 } 861 }
882 bucket_ranges->ResetChecksum(); 862 bucket_ranges->ResetChecksum();
883 return bucket_ranges; 863 return bucket_ranges;
884 } 864 }
885 865
886 } // namespace base 866 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698