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

Unified Diff: base/metrics/statistics_recorder.cc

Issue 1880803003: Display histograms from subprocesses in chrome://histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/statistics_recorder.h ('k') | chrome/browser/metrics/subprocess_metrics_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.cc
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index 4eecddade8058c723392abb32152778e3c5c59eb..65c67ce7fe44eb87eb3c8768459b4232f6f56563 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::MetricsDisplayer*>>::Leaky
+ g_metrics_displayers_ = LAZY_INSTANCE_INITIALIZER;
+
} // namespace
namespace base {
@@ -211,9 +215,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_displayers_.Get()) {
+ output->append("<hr size=10 noshade><br><hr><br>\n<p>");
+ display->WriteTitleString(output);
+ output->append("</p>\n");
+ display->WriteGraphs(query, MetricsDisplayer::DISPLAY_TEXT_HTML, output);
+ }
}
// static
@@ -230,9 +241,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_displayers_.Get()) {
+ output->append(
+ "########################################"
+ "########################################\n\n");
+ display->WriteTitleString(output);
+ output->append("\n\n");
+ display->WriteGraphs(query, MetricsDisplayer::DISPLAY_TEXT_PLAIN, output);
+ }
}
// static
@@ -415,6 +435,18 @@ size_t StatisticsRecorder::GetHistogramCount() {
}
// static
+void StatisticsRecorder::RegisterMetricsDisplayer(MetricsDisplayer* display) {
+ DCHECK(!ContainsKey(g_metrics_displayers_.Get(), display));
+ g_metrics_displayers_.Get().insert(display);
+}
+
+// static
+void StatisticsRecorder::DeregisterMetricsDisplayer(MetricsDisplayer* display) {
+ DCHECK(ContainsKey(g_metrics_displayers_.Get(), display));
+ g_metrics_displayers_.Get().erase(display);
+}
+
+// static
void StatisticsRecorder::ForgetHistogramForTesting(base::StringPiece name) {
if (histograms_)
histograms_->erase(name);
« no previous file with comments | « base/metrics/statistics_recorder.h ('k') | chrome/browser/metrics/subprocess_metrics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698