Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4811)

Unified Diff: chrome/test/base/uma_histogram_helper.cc

Issue 10829466: SampleSet -> HistogramSamples (will be reused by SparseHistogram) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/uma_histogram_helper.h ('k') | chrome_frame/metrics_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/uma_histogram_helper.cc
===================================================================
--- chrome/test/base/uma_histogram_helper.cc (revision 158017)
+++ chrome/test/base/uma_histogram_helper.cc (working copy)
@@ -30,30 +30,29 @@
void UMAHistogramHelper::ExpectUniqueSample(
const std::string& name,
- size_t bucket_id,
- base::Histogram::Count expected_count) {
+ base::HistogramBase::Sample sample,
+ base::HistogramBase::Count expected_count) {
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
- EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram) <<
- "Histogram \"" << name << "\" does not exist.";
+ EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
+ << "Histogram \"" << name << "\" does not exist.";
if (histogram) {
- base::Histogram::SampleSet samples;
- histogram->SnapshotSample(&samples);
- CheckBucketCount(name, bucket_id, expected_count, samples);
- CheckTotalCount(name, expected_count, samples);
+ scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
+ CheckBucketCount(name, sample, expected_count, *samples);
+ CheckTotalCount(name, expected_count, *samples);
}
}
-void UMAHistogramHelper::ExpectTotalCount(const std::string& name,
- base::Histogram::Count count) {
+void UMAHistogramHelper::ExpectTotalCount(
+ const std::string& name,
+ base::HistogramBase::Count count) {
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
- EXPECT_NE((base::Histogram*)NULL, histogram) << "Histogram \"" << name <<
- "\" does not exist.";
+ EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
+ << "Histogram \"" << name << "\" does not exist.";
if (histogram) {
- base::Histogram::SampleSet samples;
- histogram->SnapshotSample(&samples);
- CheckTotalCount(name, count, samples);
+ scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
+ CheckTotalCount(name, count, *samples);
}
}
@@ -61,19 +60,23 @@
MessageLoopForUI::current()->Quit();
}
-void UMAHistogramHelper::CheckBucketCount(const std::string& name,
- size_t bucket_id,
- base::Histogram::Count expected_count,
- base::Histogram::SampleSet& samples) {
- EXPECT_EQ(expected_count, samples.counts(bucket_id)) << "Histogram \"" <<
- name << "\" does not have the right number of samples (" <<
- expected_count << ") in the expected bucket (" << bucket_id << ").";
+void UMAHistogramHelper::CheckBucketCount(
+ const std::string& name,
+ base::HistogramBase::Sample sample,
+ base::HistogramBase::Count expected_count,
+ base::HistogramSamples& samples) {
+ EXPECT_EQ(expected_count, samples.GetCount(sample))
+ << "Histogram \"" << name
+ << "\" does not have the right number of samples (" << expected_count
+ << ") in the expected bucket (" << sample << ").";
}
-void UMAHistogramHelper::CheckTotalCount(const std::string& name,
- base::Histogram::Count expected_count,
- base::Histogram::SampleSet& samples) {
- EXPECT_EQ(expected_count, samples.TotalCount()) << "Histogram \"" << name <<
- "\" does not have the right total number of samples (" <<
- expected_count << ").";
+void UMAHistogramHelper::CheckTotalCount(
+ const std::string& name,
+ base::HistogramBase::Count expected_count,
+ base::HistogramSamples& samples) {
+ EXPECT_EQ(expected_count, samples.TotalCount())
+ << "Histogram \"" << name
+ << "\" does not have the right total number of samples ("
+ << expected_count << ").";
}
« no previous file with comments | « chrome/test/base/uma_histogram_helper.h ('k') | chrome_frame/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698