Chromium Code Reviews| Index: base/metrics/histogram.cc |
| diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc |
| index 86c6746c0f590199cefe57c21d35ed4fcb7bd3a2..231e9379ac0d61bf8a42738edc3760cca66f0745 100644 |
| --- a/base/metrics/histogram.cc |
| +++ b/base/metrics/histogram.cc |
| @@ -462,15 +462,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), |
|
Ilya Sherman
2016/04/13 00:29:32
Hmm, I'm not super happy about the static_cast her
bcwhite
2016/04/13 11:58:18
This is a virtual function off of HistogramBase so
|
| + 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 { |
| @@ -578,10 +582,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. |
|
Ilya Sherman
2016/04/13 00:29:32
nit: Mebbe move this comment into the if-stmt?
bcwhite
2016/04/13 11:58:18
Done.
|
| - std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
| + std::unique_ptr<SampleVector> local_snapshot; |
| + if (!snapshot) { |
| + local_snapshot = SnapshotSampleVector(); |
| + snapshot = local_snapshot.get(); |
| + } |
| Count sample_count = snapshot->TotalCount(); |
| WriteAsciiHeader(*snapshot, sample_count, output); |