Chromium Code Reviews| Index: base/metrics/sparse_histogram.cc |
| diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc |
| index 31fcfd93d63cc4d1ee14667433488510785da7ad..a163c840150667dfe2535345839571992c755c2e 100644 |
| --- a/base/metrics/sparse_histogram.cc |
| +++ b/base/metrics/sparse_histogram.cc |
| @@ -146,14 +146,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 { |
| @@ -211,9 +213,14 @@ 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. |
|
Ilya Sherman
2016/04/13 00:29:32
Ditto
bcwhite
2016/04/13 11:58:18
Done.
|
| - std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples(); |
| + std::unique_ptr<HistogramSamples> local_snapshot; |
| + if (!snapshot) { |
| + local_snapshot = SnapshotSamples(); |
| + snapshot = local_snapshot.get(); |
| + } |
| Count total_count = snapshot->TotalCount(); |
| double scaled_total_count = total_count / 100.0; |