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

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

Issue 18337014: Add a HistogramRecorder class and use cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 5 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 | Annotate | Revision Log
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 static void GetHistograms(Histograms* output); 59 static void GetHistograms(Histograms* output);
60 60
61 // Method for extracting BucketRanges used by all histograms registered. 61 // Method for extracting BucketRanges used by all histograms registered.
62 static void GetBucketRanges(std::vector<const BucketRanges*>* output); 62 static void GetBucketRanges(std::vector<const BucketRanges*>* output);
63 63
64 // Find a histogram by name. It matches the exact name. This method is thread 64 // Find a histogram by name. It matches the exact name. This method is thread
65 // safe. It returns NULL if a matching histogram is not found. 65 // safe. It returns NULL if a matching histogram is not found.
66 static HistogramBase* FindHistogram(const std::string& name); 66 static HistogramBase* FindHistogram(const std::string& name);
67 67
68 // GetSnapshot copies some of the pointers to registered histograms into the 68 // GetSnapshot copies some of the pointers to registered histograms into the
69 // caller supplied vector (Histograms). Only histograms with names matching 69 // caller supplied vector (Histograms). Only histograms which have query as
70 // query are returned. The query must be a substring of histogram name for its 70 // a substring are copied (an empty string will process all registered
71 // pointer to be copied. 71 // histograms).
72 static void GetSnapshot(const std::string& query, Histograms* snapshot); 72 static void GetSnapshot(const std::string& query, Histograms* snapshot);
73 73
74 private: 74 private:
75 // We keep all registered histograms in a map, from name to histogram. 75 // We keep all registered histograms in a map, from name to histogram.
76 typedef std::map<std::string, HistogramBase*> HistogramMap; 76 typedef std::map<std::string, HistogramBase*> HistogramMap;
77 77
78 // We keep all |bucket_ranges_| in a map, from checksum to a list of 78 // We keep all |bucket_ranges_| in a map, from checksum to a list of
79 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in 79 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in
80 // |bucket_ranges_|. 80 // |bucket_ranges_|.
81 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap; 81 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap;
(...skipping 17 matching lines...) Expand all
99 99
100 // Lock protects access to above maps. 100 // Lock protects access to above maps.
101 static base::Lock* lock_; 101 static base::Lock* lock_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 103 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
104 }; 104 };
105 105
106 } // namespace base 106 } // namespace base
107 107
108 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ 108 #endif // BASE_METRICS_STATISTICS_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698