Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef Histogram_h | 5 #ifndef Histogram_h |
| 6 #define Histogram_h | 6 #define Histogram_h |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include "base/metrics/histogram_base.h" | 9 #include "base/metrics/histogram_base.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "platform/PlatformExport.h" | 11 #include "platform/PlatformExport.h" |
| 12 #include "platform/wtf/CurrentTime.h" | 12 #include "platform/wtf/CurrentTime.h" |
| 13 #include "public/platform/WebFeature.h" | |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class HistogramBase; | 16 class HistogramBase; |
| 16 }; | 17 }; |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 class PLATFORM_EXPORT CustomCountHistogram { | 21 class PLATFORM_EXPORT CustomCountHistogram { |
| 21 public: | 22 public: |
| 22 // Min values should be >=1 as emitted 0s still go into the underflow bucket. | 23 // Min values should be >=1 as emitted 0s still go into the underflow bucket. |
| 23 CustomCountHistogram(const char* name, | 24 CustomCountHistogram(const char* name, |
| 24 base::HistogramBase::Sample min, | 25 base::HistogramBase::Sample min, |
| 25 base::HistogramBase::Sample max, | 26 base::HistogramBase::Sample max, |
| 26 int32_t bucket_count); | 27 int32_t bucket_count); |
| 27 void Count(base::HistogramBase::Sample); | 28 void Count(base::HistogramBase::Sample); |
| 29 void Count(WebFeature feature) { | |
| 30 return Count(static_cast<base::HistogramBase::Sample>(feature)); | |
|
Rick Byers
2017/05/25 01:53:24
This class is intended to be a generic part of the
| |
| 31 } | |
| 28 | 32 |
| 29 protected: | 33 protected: |
| 30 explicit CustomCountHistogram(base::HistogramBase*); | 34 explicit CustomCountHistogram(base::HistogramBase*); |
| 31 | 35 |
| 32 base::HistogramBase* histogram_; | 36 base::HistogramBase* histogram_; |
| 33 }; | 37 }; |
| 34 | 38 |
| 35 class PLATFORM_EXPORT BooleanHistogram : public CustomCountHistogram { | 39 class PLATFORM_EXPORT BooleanHistogram : public CustomCountHistogram { |
| 36 public: | 40 public: |
| 37 BooleanHistogram(const char* name); | 41 BooleanHistogram(const char* name); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // This macro records all times between 0us and 10 seconds. | 84 // This macro records all times between 0us and 10 seconds. |
| 81 // Do not change this macro without renaming all metrics that use it! | 85 // Do not change this macro without renaming all metrics that use it! |
| 82 #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \ | 86 #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \ |
| 83 DEFINE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter, \ | 87 DEFINE_STATIC_LOCAL(CustomCountHistogram, scoped_us_counter, \ |
| 84 (name, 0, 10000000, 50)); \ | 88 (name, 0, 10000000, 50)); \ |
| 85 ScopedUsHistogramTimer timer(scoped_us_counter); | 89 ScopedUsHistogramTimer timer(scoped_us_counter); |
| 86 | 90 |
| 87 } // namespace blink | 91 } // namespace blink |
| 88 | 92 |
| 89 #endif // Histogram_h | 93 #endif // Histogram_h |
| OLD | NEW |