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

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

Issue 19866004: Reland "Add a HistogramRecorder class and use cases." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: This is the fix. Created 7 years 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 static void GetHistograms(Histograms* output); 63 static void GetHistograms(Histograms* output);
64 64
65 // Method for extracting BucketRanges used by all histograms registered. 65 // Method for extracting BucketRanges used by all histograms registered.
66 static void GetBucketRanges(std::vector<const BucketRanges*>* output); 66 static void GetBucketRanges(std::vector<const BucketRanges*>* output);
67 67
68 // Find a histogram by name. It matches the exact name. This method is thread 68 // Find a histogram by name. It matches the exact name. This method is thread
69 // safe. It returns NULL if a matching histogram is not found. 69 // safe. It returns NULL if a matching histogram is not found.
70 static HistogramBase* FindHistogram(const std::string& name); 70 static HistogramBase* FindHistogram(const std::string& name);
71 71
72 // GetSnapshot copies some of the pointers to registered histograms into the 72 // GetSnapshot copies some of the pointers to registered histograms into the
73 // caller supplied vector (Histograms). Only histograms with names matching 73 // caller supplied vector (Histograms). Only histograms which have query as
ppi 2013/12/19 16:57:27 nit: remove double space, put "query" in pipes: |q
lpromero 2013/12/20 11:53:44 Done.
74 // query are returned. The query must be a substring of histogram name for its 74 // a substring are copied (an empty string will process all registered
75 // pointer to be copied. 75 // histograms).
76 static void GetSnapshot(const std::string& query, Histograms* snapshot); 76 static void GetSnapshot(const std::string& query, Histograms* snapshot);
77 77
78 private: 78 private:
79 // We keep all registered histograms in a map, from name to histogram. 79 // We keep all registered histograms in a map, from name to histogram.
80 typedef std::map<std::string, HistogramBase*> HistogramMap; 80 typedef std::map<std::string, HistogramBase*> HistogramMap;
81 81
82 // We keep all |bucket_ranges_| in a map, from checksum to a list of 82 // We keep all |bucket_ranges_| in a map, from checksum to a list of
83 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in 83 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in
84 // |bucket_ranges_|. 84 // |bucket_ranges_|.
85 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap; 85 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap;
(...skipping 19 matching lines...) Expand all
105 105
106 // Lock protects access to above maps. 106 // Lock protects access to above maps.
107 static base::Lock* lock_; 107 static base::Lock* lock_;
108 108
109 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 109 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
110 }; 110 };
111 111
112 } // namespace base 112 } // namespace base
113 113
114 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ 114 #endif // BASE_METRICS_STATISTICS_RECORDER_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/test/histogram_recorder.h » ('j') | base/test/histogram_recorder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698