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

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

Issue 1748403003: Log histograms on shutdown when verbose logging is on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove abandoned test class Created 4 years, 7 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 | « no previous file | 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 static void ClearCallback(const std::string& histogram_name); 158 static void ClearCallback(const std::string& histogram_name);
159 159
160 // FindCallback retrieves the callback for the histogram referred to by 160 // FindCallback retrieves the callback for the histogram referred to by
161 // |histogram_name|, or a null callback if no callback exists for this 161 // |histogram_name|, or a null callback if no callback exists for this
162 // histogram. This method is thread safe. 162 // histogram. This method is thread safe.
163 static OnSampleCallback FindCallback(const std::string& histogram_name); 163 static OnSampleCallback FindCallback(const std::string& histogram_name);
164 164
165 // Returns the number of known histograms. 165 // Returns the number of known histograms.
166 static size_t GetHistogramCount(); 166 static size_t GetHistogramCount();
167 167
168 // Initializes logging histograms with --v=1. Safe to call several times.
169 // Is called from ctor but for browser it seems that it is more useful to
170 // start logging after statistics recorder, so we need to init log-on-shutdown
171 // later.
172 static void InitLogOnShutdown();
173
168 // Removes a histogram from the internal set of known ones. This can be 174 // Removes a histogram from the internal set of known ones. This can be
169 // necessary during testing persistent histograms where the underlying 175 // necessary during testing persistent histograms where the underlying
170 // memory is being released. 176 // memory is being released.
171 static void ForgetHistogramForTesting(base::StringPiece name); 177 static void ForgetHistogramForTesting(base::StringPiece name);
172 178
173 // Reset any global instance of the statistics-recorder that was created 179 // Reset any global instance of the statistics-recorder that was created
174 // by a call to Initialize(). 180 // by a call to Initialize().
175 static void UninitializeForTesting(); 181 static void UninitializeForTesting();
176 182
177 private: 183 private:
(...skipping 26 matching lines...) Expand all
204 // call the constructor to get a clean StatisticsRecorder. 210 // call the constructor to get a clean StatisticsRecorder.
205 StatisticsRecorder(); 211 StatisticsRecorder();
206 212
207 // These are copies of everything that existed when the (test) Statistics- 213 // These are copies of everything that existed when the (test) Statistics-
208 // Recorder was created. The global ones have to be moved aside to create a 214 // Recorder was created. The global ones have to be moved aside to create a
209 // clean environment. 215 // clean environment.
210 std::unique_ptr<HistogramMap> existing_histograms_; 216 std::unique_ptr<HistogramMap> existing_histograms_;
211 std::unique_ptr<CallbackMap> existing_callbacks_; 217 std::unique_ptr<CallbackMap> existing_callbacks_;
212 std::unique_ptr<RangesMap> existing_ranges_; 218 std::unique_ptr<RangesMap> existing_ranges_;
213 219
220 bool vlog_initialized_ = false;
221
222 void InitLogOnShutdownWithoutLock();
Alexei Svitkine (slow) 2016/06/29 14:24:47 Nit: Add a comment.
223
214 static void Reset(); 224 static void Reset();
215 static void DumpHistogramsToVlog(void* instance); 225 static void DumpHistogramsToVlog(void* instance);
216 226
217 static HistogramMap* histograms_; 227 static HistogramMap* histograms_;
218 static CallbackMap* callbacks_; 228 static CallbackMap* callbacks_;
219 static RangesMap* ranges_; 229 static RangesMap* ranges_;
220 230
221 // Lock protects access to above maps. 231 // Lock protects access to above maps.
222 static base::Lock* lock_; 232 static base::Lock* lock_;
223 233
224 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 234 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
225 }; 235 };
226 236
227 } // namespace base 237 } // namespace base
228 238
229 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ 239 #endif // BASE_METRICS_STATISTICS_RECORDER_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698