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

Unified Diff: base/metrics/sparse_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/sparse_histogram.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram.cc
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index a2dbb61b218b9b42b90543547c344fb42d26b5cc..699f04abbc9832e762358d93e4123a0cbe5e64ed 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -161,14 +161,16 @@ bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) {
return samples_->AddFromPickle(iter);
}
-void SparseHistogram::WriteHTMLGraph(std::string* output) const {
+void SparseHistogram::WriteHTMLGraph(const HistogramSamples* snapshot,
+ std::string* output) const {
output->append("<PRE>");
- WriteAsciiImpl(true, "<br>", output);
+ WriteAsciiImpl(true, "<br>", snapshot, output);
output->append("</PRE>");
}
-void SparseHistogram::WriteAscii(std::string* output) const {
- WriteAsciiImpl(true, "\n", output);
+void SparseHistogram::WriteAscii(const HistogramSamples* snapshot,
+ std::string* output) const {
+ WriteAsciiImpl(true, "\n", snapshot, output);
}
bool SparseHistogram::SerializeInfoImpl(Pickle* pickle) const {
@@ -226,9 +228,15 @@ void SparseHistogram::GetCountAndBucketData(Count* count,
void SparseHistogram::WriteAsciiImpl(bool graph_it,
const std::string& newline,
+ const HistogramSamples* snapshot,
std::string* output) const {
- // Get a local copy of the data so we are consistent.
- std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples();
+ std::unique_ptr<HistogramSamples> 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 = SnapshotSamples();
+ snapshot = local_snapshot.get();
+ }
Count total_count = snapshot->TotalCount();
double scaled_total_count = total_count / 100.0;
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698