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); |