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

Side by Side Diff: base/metrics/sparse_histogram.h

Issue 484603006: Add LOCAL_ prefix to non-UMA histogram macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove spellcheck histograms. Created 6 years, 4 months 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
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 #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
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram_base.h" 16 #include "base/metrics/histogram_base.h"
17 #include "base/metrics/sample_map.h" 17 #include "base/metrics/sample_map.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 19
20 namespace base { 20 namespace base {
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) \
Ilya Sherman 2014/08/26 00:23:28 Optional nit: Should we perhaps add a "PRIVATE_" p
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)
Ilya Sherman 2014/08/26 00:23:28 Actually, are there any uses of local sparse histo
Alexei Svitkine (slow) 2014/08/26 00:54:01 SGTM. Done. Also, did a little bit of cleanup to
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698