Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // histogram (either the argument, or the pre-existing registered histogram). | 42 // histogram (either the argument, or the pre-existing registered histogram). |
| 43 static HistogramBase* RegisterOrDeleteDuplicate(HistogramBase* histogram); | 43 static HistogramBase* RegisterOrDeleteDuplicate(HistogramBase* histogram); |
| 44 | 44 |
| 45 // Register, or add a new BucketRanges. If an identically BucketRanges is | 45 // Register, or add a new BucketRanges. If an identically BucketRanges is |
| 46 // already registered, then the argument |ranges| will deleted. The returned | 46 // already registered, then the argument |ranges| will deleted. The returned |
| 47 // value is always the registered BucketRanges (either the argument, or the | 47 // value is always the registered BucketRanges (either the argument, or the |
| 48 // pre-existing one). | 48 // pre-existing one). |
| 49 static const BucketRanges* RegisterOrDeleteDuplicateRanges( | 49 static const BucketRanges* RegisterOrDeleteDuplicateRanges( |
| 50 const BucketRanges* ranges); | 50 const BucketRanges* ranges); |
| 51 | 51 |
| 52 // Methods for printing histograms. Only histograms which have query as | 52 // Methods for appending histogram data to a string. Only histograms which |
| 53 // a substring are written to output (an empty string will process all | 53 // have |query| as a substring are written to |output| (an empty string will |
| 54 // registered histograms). | 54 // process all registered histograms). |
| 55 static void WriteHTMLGraph(const std::string& query, std::string* output); | 55 static void WriteHTMLGraph(const std::string& query, std::string* output); |
| 56 static void WriteGraph(const std::string& query, std::string* output); | 56 static void WriteGraph(const std::string& query, std::string* output); |
| 57 | 57 |
| 58 // Returns the histograms with |query| as a substring as JSON text. | |
|
Peter Kasting
2013/11/14 07:04:06
Nit: Maybe should add "(as in Write[HTML]Graph abo
grt (UTC plus 2)
2013/11/14 14:44:12
Done.
| |
| 59 static std::string ToJSON(const std::string& query); | |
| 60 | |
| 58 // Method for extracting histograms which were marked for use by UMA. | 61 // Method for extracting histograms which were marked for use by UMA. |
| 59 static void GetHistograms(Histograms* output); | 62 static void GetHistograms(Histograms* output); |
| 60 | 63 |
| 61 // Method for extracting BucketRanges used by all histograms registered. | 64 // Method for extracting BucketRanges used by all histograms registered. |
| 62 static void GetBucketRanges(std::vector<const BucketRanges*>* output); | 65 static void GetBucketRanges(std::vector<const BucketRanges*>* output); |
| 63 | 66 |
| 64 // Find a histogram by name. It matches the exact name. This method is thread | 67 // 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. | 68 // safe. It returns NULL if a matching histogram is not found. |
| 66 static HistogramBase* FindHistogram(const std::string& name); | 69 static HistogramBase* FindHistogram(const std::string& name); |
| 67 | 70 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 104 |
| 102 // Lock protects access to above maps. | 105 // Lock protects access to above maps. |
| 103 static base::Lock* lock_; | 106 static base::Lock* lock_; |
| 104 | 107 |
| 105 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 108 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 } // namespace base | 111 } // namespace base |
| 109 | 112 |
| 110 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 113 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
| OLD | NEW |