| Index: base/metrics/statistics_recorder.cc
|
| diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
|
| index 9aafe187be23adef5d1fabaf853d109c13fc0033..d4c903cca4db6639f86da15b6b614ab08b1bc7a6 100644
|
| --- a/base/metrics/statistics_recorder.cc
|
| +++ b/base/metrics/statistics_recorder.cc
|
| @@ -5,6 +5,7 @@
|
| #include "base/metrics/statistics_recorder.h"
|
|
|
| #include <memory>
|
| +#include <set>
|
|
|
| #include "base/at_exit.h"
|
| #include "base/debug/leak_annotations.h"
|
| @@ -29,6 +30,9 @@ bool HistogramNameLesser(const base::HistogramBase* a,
|
| return a->histogram_name() < b->histogram_name();
|
| }
|
|
|
| +base::LazyInstance<std::set<base::StatisticsRecorder::MetricsDisplay*>>::Leaky
|
| + g_metrics_displays_ = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| } // namespace
|
|
|
| namespace base {
|
| @@ -203,9 +207,16 @@ void StatisticsRecorder::WriteHTMLGraph(const std::string& query,
|
| GetSnapshot(query, &snapshot);
|
| std::sort(snapshot.begin(), snapshot.end(), &HistogramNameLesser);
|
| for (const HistogramBase* histogram : snapshot) {
|
| - histogram->WriteHTMLGraph(output);
|
| + histogram->WriteHTMLGraph(nullptr, output);
|
| output->append("<br><hr><br>");
|
| }
|
| +
|
| + for (auto display : g_metrics_displays_.Get()) {
|
| + output->append("<hr size=10 noshade><br><hr><br>\n<p>");
|
| + display->WriteTitleString(output);
|
| + output->append("</p>\n");
|
| + display->WriteGraphs(query, true, output);
|
| + }
|
| }
|
|
|
| // static
|
| @@ -222,9 +233,18 @@ void StatisticsRecorder::WriteGraph(const std::string& query,
|
| GetSnapshot(query, &snapshot);
|
| std::sort(snapshot.begin(), snapshot.end(), &HistogramNameLesser);
|
| for (const HistogramBase* histogram : snapshot) {
|
| - histogram->WriteAscii(output);
|
| + histogram->WriteAscii(nullptr, output);
|
| output->append("\n");
|
| }
|
| +
|
| + for (auto display : g_metrics_displays_.Get()) {
|
| + output->append(
|
| + "########################################"
|
| + "########################################\n\n");
|
| + display->WriteTitleString(output);
|
| + output->append("\n\n");
|
| + display->WriteGraphs(query, false, output);
|
| + }
|
| }
|
|
|
| // static
|
| @@ -401,6 +421,18 @@ size_t StatisticsRecorder::GetHistogramCount() {
|
| }
|
|
|
| // static
|
| +void StatisticsRecorder::RegisterMetricsDisplay(MetricsDisplay* display) {
|
| + DCHECK(!ContainsKey(g_metrics_displays_.Get(), display));
|
| + g_metrics_displays_.Get().insert(display);
|
| +}
|
| +
|
| +// static
|
| +void StatisticsRecorder::DeregisterMetricsDisplay(MetricsDisplay* display) {
|
| + DCHECK(ContainsKey(g_metrics_displays_.Get(), display));
|
| + g_metrics_displays_.Get().erase(display);
|
| +}
|
| +
|
| +// static
|
| void StatisticsRecorder::ForgetHistogramForTesting(base::StringPiece name) {
|
| if (histograms_)
|
| histograms_->erase(name);
|
|
|