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 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_ | 5 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_ |
6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ | 6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // The common code for different SparseHistogram macros. | 22 // The common code for different SparseHistogram macros. |
23 #define HISTOGRAM_SPARSE_COMMON(name, sample, flag) \ | 23 #define HISTOGRAM_SPARSE_COMMON(name, sample, flag) \ |
24 do { \ | 24 do { \ |
25 base::HistogramBase* histogram( \ | 25 base::HistogramBase* histogram( \ |
26 base::SparseHistogram::FactoryGet(name, flag)); \ | 26 base::SparseHistogram::FactoryGet(name, flag)); \ |
27 DCHECK_EQ(histogram->histogram_name(), name); \ | 27 DCHECK_EQ(histogram->histogram_name(), name); \ |
28 histogram->Add(sample); \ | 28 histogram->Add(sample); \ |
29 } while (0) | 29 } while (0) |
30 | 30 |
31 #define HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 31 #define LOCAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
32 HISTOGRAM_SPARSE_COMMON(name, sample, base::HistogramBase::kNoFlags) | 32 HISTOGRAM_SPARSE_COMMON(name, sample, base::HistogramBase::kNoFlags) |
33 | 33 |
34 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 34 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
35 HISTOGRAM_SPARSE_COMMON(name, sample, \ | 35 HISTOGRAM_SPARSE_COMMON(name, sample, \ |
36 base::HistogramBase::kUmaTargetedHistogramFlag) | 36 base::HistogramBase::kUmaTargetedHistogramFlag) |
37 | 37 |
38 //------------------------------------------------------------------------------ | |
39 // Define debug only version of macros. | |
40 #ifndef NDEBUG | |
41 | |
42 #define DHISTOGRAM_SPARSE_SLOWLY(name, sample) \ | |
43 HISTOGRAM_SPARSE_SLOWLY(name, sample) | |
44 | |
45 #else // NDEBUG | |
46 | |
47 #define DHISTOGRAM_SPARSE_SLOWLY(name, sample) \ | |
48 while (0) { \ | |
49 static_cast<void>(name); \ | |
50 static_cast<void>(sample); \ | |
51 } | |
52 | |
53 #endif // NDEBUG | |
54 | |
55 class HistogramSamples; | 38 class HistogramSamples; |
56 | 39 |
57 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { | 40 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { |
58 public: | 41 public: |
59 // If there's one with same name, return the existing one. If not, create a | 42 // If there's one with same name, return the existing one. If not, create a |
60 // new one. | 43 // new one. |
61 static HistogramBase* FactoryGet(const std::string& name, int32 flags); | 44 static HistogramBase* FactoryGet(const std::string& name, int32 flags); |
62 | 45 |
63 virtual ~SparseHistogram(); | 46 virtual ~SparseHistogram(); |
64 | 47 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 mutable base::Lock lock_; | 91 mutable base::Lock lock_; |
109 | 92 |
110 SampleMap samples_; | 93 SampleMap samples_; |
111 | 94 |
112 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 95 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
113 }; | 96 }; |
114 | 97 |
115 } // namespace base | 98 } // namespace base |
116 | 99 |
117 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 100 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
OLD | NEW |