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