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

Unified Diff: base/metrics/histogram.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/histogram.h ('k') | base/metrics/histogram_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.cc
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 3571657513f6482c5724f721c17e8a2c354ab79a..8af73e91d098e2e753a775b870d39c7d1208d44e 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -476,15 +476,19 @@ bool Histogram::AddSamplesFromPickle(PickleIterator* iter) {
}
// The following methods provide a graphical histogram display.
-void Histogram::WriteHTMLGraph(std::string* output) const {
+void Histogram::WriteHTMLGraph(const HistogramSamples* snapshot,
+ std::string* output) const {
// TBD(jar) Write a nice HTML bar chart, with divs an mouse-overs etc.
output->append("<PRE>");
- WriteAsciiImpl(true, "<br>", output);
+ WriteAsciiImpl(true, "<br>", static_cast<const SampleVector*>(snapshot),
+ output);
output->append("</PRE>");
}
-void Histogram::WriteAscii(std::string* output) const {
- WriteAsciiImpl(true, "\n", output);
+void Histogram::WriteAscii(const HistogramSamples* snapshot,
+ std::string* output) const {
+ WriteAsciiImpl(true, "\n", static_cast<const SampleVector*>(snapshot),
+ output);
}
bool Histogram::SerializeInfoImpl(Pickle* pickle) const {
@@ -592,10 +596,15 @@ std::unique_ptr<SampleVector> Histogram::SnapshotSampleVector() const {
void Histogram::WriteAsciiImpl(bool graph_it,
const std::string& newline,
+ const SampleVector* snapshot,
std::string* output) const {
- // Get local (stack) copies of all effectively volatile class data so that we
- // are consistent across our output activities.
- std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector();
+ std::unique_ptr<SampleVector> local_snapshot;
+ if (!snapshot) {
+ // Get local (stack) copies of all effectively volatile class data so
+ // that we are consistent across our output activities.
+ local_snapshot = SnapshotSampleVector();
+ snapshot = local_snapshot.get();
+ }
Count sample_count = snapshot->TotalCount();
WriteAsciiHeader(*snapshot, sample_count, output);
« no previous file with comments | « base/metrics/histogram.h ('k') | base/metrics/histogram_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698