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

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

Issue 1726873002: Report histogram creation results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 9 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
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // StatisticsRecorder holds all Histograms and BucketRanges that are used by 5 // StatisticsRecorder holds all Histograms and BucketRanges that are used by
6 // Histograms in the system. It provides a general place for 6 // Histograms in the system. It provides a general place for
7 // Histograms/BucketRanges to register, and supports a global API for accessing 7 // Histograms/BucketRanges to register, and supports a global API for accessing
8 // (i.e., dumping, or graphing) the data. 8 // (i.e., dumping, or graphing) the data.
9 9
10 #ifndef BASE_METRICS_STATISTICS_RECORDER_H_ 10 #ifndef BASE_METRICS_STATISTICS_RECORDER_H_
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 bool operator!=(const HistogramIterator& rhs) const { 56 bool operator!=(const HistogramIterator& rhs) const {
57 return iter_ != rhs.iter_; 57 return iter_ != rhs.iter_;
58 } 58 }
59 HistogramBase* operator*() { return iter_->second; } 59 HistogramBase* operator*() { return iter_->second; }
60 60
61 private: 61 private:
62 HistogramMap::iterator iter_; 62 HistogramMap::iterator iter_;
63 const bool include_persistent_; 63 const bool include_persistent_;
64 }; 64 };
65 65
66 ~StatisticsRecorder();
67
66 // Initializes the StatisticsRecorder system. Safe to call multiple times. 68 // Initializes the StatisticsRecorder system. Safe to call multiple times.
67 static void Initialize(); 69 static void Initialize();
68 70
69 // Find out if histograms can now be registered into our list. 71 // Find out if histograms can now be registered into our list.
70 static bool IsActive(); 72 static bool IsActive();
71 73
72 // Register, or add a new histogram to the collection of statistics. If an 74 // Register, or add a new histogram to the collection of statistics. If an
73 // identically named histogram is already registered, then the argument 75 // identically named histogram is already registered, then the argument
74 // |histogram| will deleted. The returned value is always the registered 76 // |histogram| will deleted. The returned value is always the registered
75 // histogram (either the argument, or the pre-existing registered histogram). 77 // histogram (either the argument, or the pre-existing registered histogram).
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 125
124 // ClearCallback clears any callback set on the histogram referred to by 126 // ClearCallback clears any callback set on the histogram referred to by
125 // |histogram_name|. This method is thread safe. 127 // |histogram_name|. This method is thread safe.
126 static void ClearCallback(const std::string& histogram_name); 128 static void ClearCallback(const std::string& histogram_name);
127 129
128 // FindCallback retrieves the callback for the histogram referred to by 130 // FindCallback retrieves the callback for the histogram referred to by
129 // |histogram_name|, or a null callback if no callback exists for this 131 // |histogram_name|, or a null callback if no callback exists for this
130 // histogram. This method is thread safe. 132 // histogram. This method is thread safe.
131 static OnSampleCallback FindCallback(const std::string& histogram_name); 133 static OnSampleCallback FindCallback(const std::string& histogram_name);
132 134
135 // Returns the number of known histograms.
136 static size_t GetHistogramCount();
137
133 // Clears all of the known histograms and resets static variables to a 138 // Clears all of the known histograms and resets static variables to a
134 // state that allows a new initialization. 139 // state that allows a new initialization.
135 static void ResetForTesting(); 140 static void ResetForTesting();
136 141
137 // Removes a histogram from the internal set of known ones. This can be 142 // Removes a histogram from the internal set of known ones. This can be
138 // necessary during testing persistent histograms where the underlying 143 // necessary during testing persistent histograms where the underlying
139 // memory is being released. 144 // memory is being released.
140 static void ForgetHistogramForTesting(base::StringPiece name); 145 static void ForgetHistogramForTesting(base::StringPiece name);
141 146
142 private: 147 private:
(...skipping 12 matching lines...) Expand all
155 friend class HistogramTest; 160 friend class HistogramTest;
156 friend class JsonPrefStoreTest; 161 friend class JsonPrefStoreTest;
157 friend class SharedHistogramTest; 162 friend class SharedHistogramTest;
158 friend class SparseHistogramTest; 163 friend class SparseHistogramTest;
159 friend class StatisticsRecorderTest; 164 friend class StatisticsRecorderTest;
160 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, 165 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest,
161 DeserializeHistogramAndAddSamples); 166 DeserializeHistogramAndAddSamples);
162 167
163 // The constructor just initializes static members. Usually client code should 168 // The constructor just initializes static members. Usually client code should
164 // use Initialize to do this. But in test code, you can friend this class and 169 // use Initialize to do this. But in test code, you can friend this class and
165 // call destructor/constructor to get a clean StatisticsRecorder. 170 // call the constructor to get a clean StatisticsRecorder.
166 StatisticsRecorder(); 171 StatisticsRecorder();
167 ~StatisticsRecorder();
168 172
169 static void Reset(); 173 static void Reset();
170 static void DumpHistogramsToVlog(void* instance); 174 static void DumpHistogramsToVlog(void* instance);
171 175
172 static HistogramMap* histograms_; 176 static HistogramMap* histograms_;
173 static CallbackMap* callbacks_; 177 static CallbackMap* callbacks_;
174 static RangesMap* ranges_; 178 static RangesMap* ranges_;
175 179
176 // Lock protects access to above maps. 180 // Lock protects access to above maps.
177 static base::Lock* lock_; 181 static base::Lock* lock_;
178 182
179 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 183 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
180 }; 184 };
181 185
182 } // namespace base 186 } // namespace base
183 187
184 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ 188 #endif // BASE_METRICS_STATISTICS_RECORDER_H_
OLDNEW
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698