Index: base/metrics/histogram.h |
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h |
index 7a6c6885e5ecb74b54c753b5e31a2f7bb2716f3e..e3ac09ec5d052f979ee09c7685c2be5ada5d3e69 100644 |
--- a/base/metrics/histogram.h |
+++ b/base/metrics/histogram.h |
@@ -135,6 +135,25 @@ class Lock; |
} while (0); |
*/ |
+#define SMALL_STATIC_HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \ |
+ histogram_add_method_invocation, \ |
+ histogram_factory_get_name, \ |
+ ...) \ |
+ do { \ |
+ static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ |
+ base::HistogramBase* histogram_pointer( \ |
+ reinterpret_cast<base::HistogramBase*>( \ |
+ base::subtle::Acquire_Load(&atomic_histogram_pointer))); \ |
+ if (!histogram_pointer) { \ |
+ histogram_pointer = \ |
+ histogram_factory_get_name##AndAtomicRelease(&atomic_histogram_pointer, \ |
+ __VA_ARGS__); \ |
+ } \ |
+ DCHECK_EQ(histogram_pointer->histogram_name(), \ |
+ std::string(constant_histogram_name)); \ |
+ histogram_pointer->histogram_add_method_invocation; \ |
+ } while (0) |
+ |
// The above pattern is repeated in several macros. The only elements that |
// vary are the invocation of the Add(sample) vs AddTime(sample), and the choice |
// of which FactoryGet method to use. The different FactoryGet methods have |
@@ -152,7 +171,7 @@ class Lock; |
base::subtle::Acquire_Load(&atomic_histogram_pointer))); \ |
if (!histogram_pointer) { \ |
histogram_pointer = histogram_factory_get_invocation; \ |
- base::subtle::Release_Store(&atomic_histogram_pointer, \ |
+ base::subtle::NoBarrier_Store(&atomic_histogram_pointer, \ |
reinterpret_cast<base::subtle::AtomicWord>(histogram_pointer)); \ |
} \ |
DCHECK_EQ(histogram_pointer->histogram_name(), \ |
@@ -171,10 +190,17 @@ class Lock; |
// For folks that need real specific times, use this to select a precise range |
// of times you want plotted, and the number of buckets you want used. |
-#define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
- STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ |
+#if 1 |
+#define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
+ STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ |
base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ |
base::HistogramBase::kNoFlags)) |
+#else |
+#define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
+ SMALL_STATIC_HISTOGRAM_POINTER_BLOCK( \ |
+ name, AddTime(sample), base::Histogram::FactoryTimeGet, \ |
+ name, min, max, bucket_count, base::HistogramBase::kNoFlags) |
+#endif |
#define HISTOGRAM_COUNTS(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ |
name, sample, 1, 1000000, 50) |
@@ -407,6 +433,13 @@ class BASE_EXPORT Histogram : public HistogramBase { |
base::TimeDelta maximum, |
size_t bucket_count, |
int32 flags); |
+ static HistogramBase* FactoryTimeGetAndAtomicRelease( |
+ base::subtle::AtomicWord* atomic_histogram_pointer, |
+ const std::string& name, |
+ base::TimeDelta minimum, |
+ base::TimeDelta maximum, |
+ size_t bucket_count, |
+ int32 flags); |
// Time call for use with DHISTOGRAM*. |
// Returns TimeTicks::Now() in debug and TimeTicks() in release build. |