| OLD | NEW |
| 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 | 8 |
| 9 // It supports calls to accumulate either time intervals (which are processed | 9 // It supports calls to accumulate either time intervals (which are processed |
| 10 // as integral number of milliseconds), or arbitrary integral units. | 10 // as integral number of milliseconds), or arbitrary integral units. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 #ifndef BASE_METRICS_HISTOGRAM_H_ | 58 #ifndef BASE_METRICS_HISTOGRAM_H_ |
| 59 #define BASE_METRICS_HISTOGRAM_H_ | 59 #define BASE_METRICS_HISTOGRAM_H_ |
| 60 | 60 |
| 61 #include <map> | 61 #include <map> |
| 62 #include <string> | 62 #include <string> |
| 63 #include <vector> | 63 #include <vector> |
| 64 | 64 |
| 65 #include "base/atomicops.h" | 65 #include "base/atomicops.h" |
| 66 #include "base/base_export.h" | 66 #include "base/base_export.h" |
| 67 #include "base/basictypes.h" |
| 67 #include "base/compiler_specific.h" | 68 #include "base/compiler_specific.h" |
| 68 #include "base/gtest_prod_util.h" | 69 #include "base/gtest_prod_util.h" |
| 69 #include "base/logging.h" | 70 #include "base/logging.h" |
| 70 #include "base/metrics/bucket_ranges.h" | 71 #include "base/metrics/bucket_ranges.h" |
| 71 #include "base/metrics/histogram_base.h" | 72 #include "base/metrics/histogram_base.h" |
| 72 #include "base/time.h" | 73 #include "base/time.h" |
| 73 | 74 |
| 74 class Pickle; | 75 class Pickle; |
| 75 class PickleIterator; | 76 class PickleIterator; |
| 76 | 77 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 101 // Acquire_Load() ensures that we acquire visibility to the pointed-to data | 102 // Acquire_Load() ensures that we acquire visibility to the pointed-to data |
| 102 // in the histogrom. | 103 // in the histogrom. |
| 103 base::Histogram* histogram_pointer(reinterpret_cast<base::Histogram*>( | 104 base::Histogram* histogram_pointer(reinterpret_cast<base::Histogram*>( |
| 104 base::subtle::Acquire_Load(&atomic_histogram_pointer))); | 105 base::subtle::Acquire_Load(&atomic_histogram_pointer))); |
| 105 | 106 |
| 106 if (!histogram_pointer) { | 107 if (!histogram_pointer) { |
| 107 // This is the slow path, which will construct OR find the matching | 108 // This is the slow path, which will construct OR find the matching |
| 108 // histogram. FactoryGet includes locks on a global histogram name map | 109 // histogram. FactoryGet includes locks on a global histogram name map |
| 109 // and is completely thread safe. | 110 // and is completely thread safe. |
| 110 histogram_pointer = base::Histogram::FactoryGet( | 111 histogram_pointer = base::Histogram::FactoryGet( |
| 111 name, min, max, bucket_count, base::Histogram::kNoFlags); | 112 name, min, max, bucket_count, base::HistogramBase::kNoFlags); |
| 112 | 113 |
| 113 // Use Release_Store to ensure that the histogram data is made available | 114 // Use Release_Store to ensure that the histogram data is made available |
| 114 // globally before we make the pointer visible. | 115 // globally before we make the pointer visible. |
| 115 // Several threads may perform this store, but the same value will be | 116 // Several threads may perform this store, but the same value will be |
| 116 // stored in all cases (for a given named/spec'ed histogram). | 117 // stored in all cases (for a given named/spec'ed histogram). |
| 117 // We could do this without any barrier, since FactoryGet entered and | 118 // We could do this without any barrier, since FactoryGet entered and |
| 118 // exited a lock after construction, but this barrier makes things clear. | 119 // exited a lock after construction, but this barrier makes things clear. |
| 119 base::subtle::Release_Store(&atomic_histogram_pointer, | 120 base::subtle::Release_Store(&atomic_histogram_pointer, |
| 120 reinterpret_cast<base::subtle::AtomicWord>(histogram_pointer)); | 121 reinterpret_cast<base::subtle::AtomicWord>(histogram_pointer)); |
| 121 } | 122 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 165 |
| 165 #define HISTOGRAM_COUNTS_100(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ | 166 #define HISTOGRAM_COUNTS_100(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ |
| 166 name, sample, 1, 100, 50) | 167 name, sample, 1, 100, 50) |
| 167 | 168 |
| 168 #define HISTOGRAM_COUNTS_10000(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ | 169 #define HISTOGRAM_COUNTS_10000(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ |
| 169 name, sample, 1, 10000, 50) | 170 name, sample, 1, 10000, 50) |
| 170 | 171 |
| 171 #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 172 #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 172 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 173 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 173 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 174 base::Histogram::FactoryGet(name, min, max, bucket_count, \ |
| 174 base::Histogram::kNoFlags)) | 175 base::HistogramBase::kNoFlags)) |
| 175 | 176 |
| 176 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 177 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 177 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 178 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
| 178 | 179 |
| 179 // For folks that need real specific times, use this to select a precise range | 180 // For folks that need real specific times, use this to select a precise range |
| 180 // of times you want plotted, and the number of buckets you want used. | 181 // of times you want plotted, and the number of buckets you want used. |
| 181 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 182 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 182 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ | 183 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ |
| 183 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ | 184 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ |
| 184 base::Histogram::kNoFlags)) | 185 base::HistogramBase::kNoFlags)) |
| 185 | 186 |
| 186 // Support histograming of an enumerated value. The samples should always be | 187 // Support histograming of an enumerated value. The samples should always be |
| 187 // strictly less than |boundary_value| -- this prevents you from running into | 188 // strictly less than |boundary_value| -- this prevents you from running into |
| 188 // problems down the line if you add additional buckets to the histogram. Note | 189 // problems down the line if you add additional buckets to the histogram. Note |
| 189 // also that, despite explicitly setting the minimum bucket value to |1| below, | 190 // also that, despite explicitly setting the minimum bucket value to |1| below, |
| 190 // it is fine for enumerated histograms to be 0-indexed -- this is because | 191 // it is fine for enumerated histograms to be 0-indexed -- this is because |
| 191 // enumerated histograms should never have underflow. | 192 // enumerated histograms should never have underflow. |
| 192 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 193 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
| 193 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 194 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 194 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ | 195 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ |
| 195 boundary_value + 1, base::Histogram::kNoFlags)) | 196 boundary_value + 1, base::HistogramBase::kNoFlags)) |
| 196 | 197 |
| 197 // Support histograming of an enumerated value. Samples should be one of the | 198 // Support histograming of an enumerated value. Samples should be one of the |
| 198 // std::vector<int> list provided via |custom_ranges|. See comments above | 199 // std::vector<int> list provided via |custom_ranges|. See comments above |
| 199 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. | 200 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. |
| 200 // You can use the helper function CustomHistogram::ArrayToCustomRanges to | 201 // You can use the helper function CustomHistogram::ArrayToCustomRanges to |
| 201 // transform a C-style array of valid sample values to a std::vector<int>. | 202 // transform a C-style array of valid sample values to a std::vector<int>. |
| 202 #define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 203 #define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
| 203 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 204 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 204 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 205 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
| 205 base::Histogram::kNoFlags)) | 206 base::HistogramBase::kNoFlags)) |
| 206 | 207 |
| 207 //------------------------------------------------------------------------------ | 208 //------------------------------------------------------------------------------ |
| 208 // Define Debug vs non-debug flavors of macros. | 209 // Define Debug vs non-debug flavors of macros. |
| 209 #ifndef NDEBUG | 210 #ifndef NDEBUG |
| 210 | 211 |
| 211 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) | 212 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) |
| 212 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) | 213 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) |
| 213 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ | 214 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ |
| 214 name, under_one_hundred) | 215 name, under_one_hundred) |
| 215 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 216 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 CUSTOM_HISTOGRAM, | 360 CUSTOM_HISTOGRAM, |
| 360 NOT_VALID_IN_RENDERER, | 361 NOT_VALID_IN_RENDERER, |
| 361 }; | 362 }; |
| 362 | 363 |
| 363 enum BucketLayout { | 364 enum BucketLayout { |
| 364 EXPONENTIAL, | 365 EXPONENTIAL, |
| 365 LINEAR, | 366 LINEAR, |
| 366 CUSTOM, | 367 CUSTOM, |
| 367 }; | 368 }; |
| 368 | 369 |
| 369 enum Flags { | |
| 370 kNoFlags = 0, | |
| 371 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded. | |
| 372 | |
| 373 // Indicate that the histogram was pickled to be sent across an IPC Channel. | |
| 374 // If we observe this flag on a histogram being aggregated into after IPC, | |
| 375 // then we are running in a single process mode, and the aggregation should | |
| 376 // not take place (as we would be aggregating back into the source | |
| 377 // histogram!). | |
| 378 kIPCSerializationSourceFlag = 0x10, | |
| 379 | |
| 380 kHexRangePrintingFlag = 0x8000, // Fancy bucket-naming supported. | |
| 381 }; | |
| 382 | |
| 383 enum Inconsistencies { | 370 enum Inconsistencies { |
| 384 NO_INCONSISTENCIES = 0x0, | 371 NO_INCONSISTENCIES = 0x0, |
| 385 RANGE_CHECKSUM_ERROR = 0x1, | 372 RANGE_CHECKSUM_ERROR = 0x1, |
| 386 BUCKET_ORDER_ERROR = 0x2, | 373 BUCKET_ORDER_ERROR = 0x2, |
| 387 COUNT_HIGH_ERROR = 0x4, | 374 COUNT_HIGH_ERROR = 0x4, |
| 388 COUNT_LOW_ERROR = 0x8, | 375 COUNT_LOW_ERROR = 0x8, |
| 389 | 376 |
| 390 NEVER_EXCEEDED_VALUE = 0x10 | 377 NEVER_EXCEEDED_VALUE = 0x10 |
| 391 }; | 378 }; |
| 392 | 379 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 // maximum > minimum | 440 // maximum > minimum |
| 454 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] | 441 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] |
| 455 // Additionally, | 442 // Additionally, |
| 456 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have | 443 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have |
| 457 // more buckets than the range of numbers; having more buckets than 1 per | 444 // more buckets than the range of numbers; having more buckets than 1 per |
| 458 // value in the range would be nonsensical. | 445 // value in the range would be nonsensical. |
| 459 static Histogram* FactoryGet(const std::string& name, | 446 static Histogram* FactoryGet(const std::string& name, |
| 460 Sample minimum, | 447 Sample minimum, |
| 461 Sample maximum, | 448 Sample maximum, |
| 462 size_t bucket_count, | 449 size_t bucket_count, |
| 463 Flags flags); | 450 int32 flags); |
| 464 static Histogram* FactoryTimeGet(const std::string& name, | 451 static Histogram* FactoryTimeGet(const std::string& name, |
| 465 base::TimeDelta minimum, | 452 base::TimeDelta minimum, |
| 466 base::TimeDelta maximum, | 453 base::TimeDelta maximum, |
| 467 size_t bucket_count, | 454 size_t bucket_count, |
| 468 Flags flags); | 455 int32 flags); |
| 469 | 456 |
| 470 // Time call for use with DHISTOGRAM*. | 457 // Time call for use with DHISTOGRAM*. |
| 471 // Returns TimeTicks::Now() in debug and TimeTicks() in release build. | 458 // Returns TimeTicks::Now() in debug and TimeTicks() in release build. |
| 472 static TimeTicks DebugNow(); | 459 static TimeTicks DebugNow(); |
| 473 | 460 |
| 474 static void InitializeBucketRanges(Sample minimum, | 461 static void InitializeBucketRanges(Sample minimum, |
| 475 Sample maximum, | 462 Sample maximum, |
| 476 size_t bucket_count, | 463 size_t bucket_count, |
| 477 BucketRanges* ranges); | 464 BucketRanges* ranges); |
| 478 | 465 |
| 479 virtual void Add(Sample value) OVERRIDE; | 466 virtual void Add(Sample value) OVERRIDE; |
| 480 | 467 |
| 481 // This method is an interface, used only by BooleanHistogram. | 468 // This method is an interface, used only by BooleanHistogram. |
| 482 virtual void AddBoolean(bool value); | 469 virtual void AddBoolean(bool value); |
| 483 | 470 |
| 484 // Accept a TimeDelta to increment. | 471 // Accept a TimeDelta to increment. |
| 485 void AddTime(TimeDelta time) { | 472 void AddTime(TimeDelta time) { |
| 486 Add(static_cast<int>(time.InMilliseconds())); | 473 Add(static_cast<int>(time.InMilliseconds())); |
| 487 } | 474 } |
| 488 | 475 |
| 489 void AddSampleSet(const SampleSet& sample); | 476 void AddSampleSet(const SampleSet& sample); |
| 490 | 477 |
| 491 // This method is an interface, used only by LinearHistogram. | 478 // This method is an interface, used only by LinearHistogram. |
| 492 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); | 479 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); |
| 493 | 480 |
| 494 // The following methods provide graphical histogram displays. | 481 // The following methods provide graphical histogram displays. |
| 495 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; | 482 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; |
| 496 virtual void WriteAscii(std::string* output) const OVERRIDE; | 483 virtual void WriteAscii(std::string* output) const OVERRIDE; |
| 497 | 484 |
| 498 // Support generic flagging of Histograms. | |
| 499 // 0x1 Currently used to mark this histogram to be recorded by UMA.. | |
| 500 // 0x8000 means print ranges in hex. | |
| 501 void SetFlags(Flags flags) { flags_ = static_cast<Flags> (flags_ | flags); } | |
| 502 void ClearFlags(Flags flags) { flags_ = static_cast<Flags>(flags_ & ~flags); } | |
| 503 int flags() const { return flags_; } | |
| 504 | |
| 505 // Convenience methods for serializing/deserializing the histograms. | 485 // Convenience methods for serializing/deserializing the histograms. |
| 506 // Histograms from Renderer process are serialized and sent to the browser. | 486 // Histograms from Renderer process are serialized and sent to the browser. |
| 507 // Browser process reconstructs the histogram from the pickled version | 487 // Browser process reconstructs the histogram from the pickled version |
| 508 // accumulates the browser-side shadow copy of histograms (that mirror | 488 // accumulates the browser-side shadow copy of histograms (that mirror |
| 509 // histograms created in the renderer). | 489 // histograms created in the renderer). |
| 510 | 490 |
| 511 // Serialize the given snapshot of a Histogram into a String. Uses | 491 // Serialize the given snapshot of a Histogram into a String. Uses |
| 512 // Pickle class to flatten the object. | 492 // Pickle class to flatten the object. |
| 513 static std::string SerializeHistogramInfo(const Histogram& histogram, | 493 static std::string SerializeHistogramInfo(const Histogram& histogram, |
| 514 const SampleSet& snapshot); | 494 const SampleSet& snapshot); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 void WriteAsciiBucketGraph(double current_size, double max_size, | 611 void WriteAsciiBucketGraph(double current_size, double max_size, |
| 632 std::string* output) const; | 612 std::string* output) const; |
| 633 | 613 |
| 634 // Does not own this object. Should get from StatisticsRecorder. | 614 // Does not own this object. Should get from StatisticsRecorder. |
| 635 const BucketRanges* bucket_ranges_; | 615 const BucketRanges* bucket_ranges_; |
| 636 | 616 |
| 637 Sample declared_min_; // Less than this goes into counts_[0] | 617 Sample declared_min_; // Less than this goes into counts_[0] |
| 638 Sample declared_max_; // Over this goes into counts_[bucket_count_ - 1]. | 618 Sample declared_max_; // Over this goes into counts_[bucket_count_ - 1]. |
| 639 size_t bucket_count_; // Dimension of counts_[]. | 619 size_t bucket_count_; // Dimension of counts_[]. |
| 640 | 620 |
| 641 // Flag the histogram for recording by UMA via metric_services.h. | |
| 642 Flags flags_; | |
| 643 | |
| 644 // Finally, provide the state that changes with the addition of each new | 621 // Finally, provide the state that changes with the addition of each new |
| 645 // sample. | 622 // sample. |
| 646 SampleSet sample_; | 623 SampleSet sample_; |
| 647 | 624 |
| 648 DISALLOW_COPY_AND_ASSIGN(Histogram); | 625 DISALLOW_COPY_AND_ASSIGN(Histogram); |
| 649 }; | 626 }; |
| 650 | 627 |
| 651 //------------------------------------------------------------------------------ | 628 //------------------------------------------------------------------------------ |
| 652 | 629 |
| 653 // LinearHistogram is a more traditional histogram, with evenly spaced | 630 // LinearHistogram is a more traditional histogram, with evenly spaced |
| 654 // buckets. | 631 // buckets. |
| 655 class BASE_EXPORT LinearHistogram : public Histogram { | 632 class BASE_EXPORT LinearHistogram : public Histogram { |
| 656 public: | 633 public: |
| 657 virtual ~LinearHistogram(); | 634 virtual ~LinearHistogram(); |
| 658 | 635 |
| 659 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit | 636 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit |
| 660 default underflow bucket. */ | 637 default underflow bucket. */ |
| 661 static Histogram* FactoryGet(const std::string& name, | 638 static Histogram* FactoryGet(const std::string& name, |
| 662 Sample minimum, | 639 Sample minimum, |
| 663 Sample maximum, | 640 Sample maximum, |
| 664 size_t bucket_count, | 641 size_t bucket_count, |
| 665 Flags flags); | 642 int32 flags); |
| 666 static Histogram* FactoryTimeGet(const std::string& name, | 643 static Histogram* FactoryTimeGet(const std::string& name, |
| 667 TimeDelta minimum, | 644 TimeDelta minimum, |
| 668 TimeDelta maximum, | 645 TimeDelta maximum, |
| 669 size_t bucket_count, | 646 size_t bucket_count, |
| 670 Flags flags); | 647 int32 flags); |
| 671 | 648 |
| 672 static void InitializeBucketRanges(Sample minimum, | 649 static void InitializeBucketRanges(Sample minimum, |
| 673 Sample maximum, | 650 Sample maximum, |
| 674 size_t bucket_count, | 651 size_t bucket_count, |
| 675 BucketRanges* ranges); | 652 BucketRanges* ranges); |
| 676 | 653 |
| 677 // Overridden from Histogram: | 654 // Overridden from Histogram: |
| 678 virtual ClassType histogram_type() const OVERRIDE; | 655 virtual ClassType histogram_type() const OVERRIDE; |
| 679 | 656 |
| 680 // Store a list of number/text values for use in rendering the histogram. | 657 // Store a list of number/text values for use in rendering the histogram. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 707 BucketDescriptionMap bucket_description_; | 684 BucketDescriptionMap bucket_description_; |
| 708 | 685 |
| 709 DISALLOW_COPY_AND_ASSIGN(LinearHistogram); | 686 DISALLOW_COPY_AND_ASSIGN(LinearHistogram); |
| 710 }; | 687 }; |
| 711 | 688 |
| 712 //------------------------------------------------------------------------------ | 689 //------------------------------------------------------------------------------ |
| 713 | 690 |
| 714 // BooleanHistogram is a histogram for booleans. | 691 // BooleanHistogram is a histogram for booleans. |
| 715 class BASE_EXPORT BooleanHistogram : public LinearHistogram { | 692 class BASE_EXPORT BooleanHistogram : public LinearHistogram { |
| 716 public: | 693 public: |
| 717 static Histogram* FactoryGet(const std::string& name, Flags flags); | 694 static Histogram* FactoryGet(const std::string& name, int32 flags); |
| 718 | 695 |
| 719 virtual ClassType histogram_type() const OVERRIDE; | 696 virtual ClassType histogram_type() const OVERRIDE; |
| 720 | 697 |
| 721 virtual void AddBoolean(bool value) OVERRIDE; | 698 virtual void AddBoolean(bool value) OVERRIDE; |
| 722 | 699 |
| 723 private: | 700 private: |
| 724 BooleanHistogram(const std::string& name, const BucketRanges* ranges); | 701 BooleanHistogram(const std::string& name, const BucketRanges* ranges); |
| 725 | 702 |
| 726 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); | 703 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); |
| 727 }; | 704 }; |
| 728 | 705 |
| 729 //------------------------------------------------------------------------------ | 706 //------------------------------------------------------------------------------ |
| 730 | 707 |
| 731 // CustomHistogram is a histogram for a set of custom integers. | 708 // CustomHistogram is a histogram for a set of custom integers. |
| 732 class BASE_EXPORT CustomHistogram : public Histogram { | 709 class BASE_EXPORT CustomHistogram : public Histogram { |
| 733 public: | 710 public: |
| 734 // |custom_ranges| contains a vector of limits on ranges. Each limit should be | 711 // |custom_ranges| contains a vector of limits on ranges. Each limit should be |
| 735 // > 0 and < kSampleType_MAX. (Currently 0 is still accepted for backward | 712 // > 0 and < kSampleType_MAX. (Currently 0 is still accepted for backward |
| 736 // compatibility). The limits can be unordered or contain duplication, but | 713 // compatibility). The limits can be unordered or contain duplication, but |
| 737 // client should not depend on this. | 714 // client should not depend on this. |
| 738 static Histogram* FactoryGet(const std::string& name, | 715 static Histogram* FactoryGet(const std::string& name, |
| 739 const std::vector<Sample>& custom_ranges, | 716 const std::vector<Sample>& custom_ranges, |
| 740 Flags flags); | 717 int32 flags); |
| 741 | 718 |
| 742 // Overridden from Histogram: | 719 // Overridden from Histogram: |
| 743 virtual ClassType histogram_type() const OVERRIDE; | 720 virtual ClassType histogram_type() const OVERRIDE; |
| 744 | 721 |
| 745 // Helper method for transforming an array of valid enumeration values | 722 // Helper method for transforming an array of valid enumeration values |
| 746 // to the std::vector<int> expected by HISTOGRAM_CUSTOM_ENUMERATION. | 723 // to the std::vector<int> expected by HISTOGRAM_CUSTOM_ENUMERATION. |
| 747 // This function ensures that a guard bucket exists right after any | 724 // This function ensures that a guard bucket exists right after any |
| 748 // valid sample value (unless the next higher sample is also a valid value), | 725 // valid sample value (unless the next higher sample is also a valid value), |
| 749 // so that invalid samples never fall into the same bucket as valid samples. | 726 // so that invalid samples never fall into the same bucket as valid samples. |
| 750 // TODO(kaiwang): Change name to ArrayToCustomEnumRanges. | 727 // TODO(kaiwang): Change name to ArrayToCustomEnumRanges. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 767 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 744 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 768 static BucketRanges* CreateBucketRangesFromCustomRanges( | 745 static BucketRanges* CreateBucketRangesFromCustomRanges( |
| 769 const std::vector<Sample>& custom_ranges); | 746 const std::vector<Sample>& custom_ranges); |
| 770 | 747 |
| 771 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 748 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 772 }; | 749 }; |
| 773 | 750 |
| 774 } // namespace base | 751 } // namespace base |
| 775 | 752 |
| 776 #endif // BASE_METRICS_HISTOGRAM_H_ | 753 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |