Index: base/test/histogram_tester.cc |
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc |
index ea738b0557b6e864a7e68c7d840c079d5c5967d8..0eba3a9a27938e6ef7ecd7872f466159284a5717 100644 |
--- a/base/test/histogram_tester.cc |
+++ b/base/test/histogram_tester.cc |
@@ -73,6 +73,19 @@ void HistogramTester::ExpectTotalCount(const std::string& name, |
} |
} |
+std::vector<Bucket> HistogramTester::GetAllSamples(const std::string& name) { |
+ std::vector<Bucket> samples; |
+ scoped_ptr<HistogramSamples> snapshot = |
+ GetHistogramSamplesSinceCreation(name); |
+ for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) { |
+ HistogramBase::Sample sample; |
+ HistogramBase::Count count; |
+ it->Get(&sample, nullptr, &count); |
+ samples.push_back(Bucket(sample, count)); |
+ } |
+ return samples; |
+} |
+ |
scoped_ptr<HistogramSamples> HistogramTester::GetHistogramSamplesSinceCreation( |
const std::string& histogram_name) { |
HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name); |
@@ -120,4 +133,12 @@ void HistogramTester::CheckTotalCount( |
<< expected_count << "). It has (" << actual_count << ")."; |
} |
+bool Bucket::operator==(const Bucket& other) const { |
+ return min == other.min && count == other.count; |
+} |
+ |
+void PrintTo(const Bucket& bucket, std::ostream* os) { |
+ *os << "Bucket " << bucket.min << ": " << bucket.count; |
+} |
+ |
} // namespace base |