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

Unified Diff: base/test/histogram_tester.cc

Issue 2796283005: Adding UseCounter specific for extensions (Closed)
Patch Set: Fix compile err Created 3 years, 7 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 | « base/test/histogram_tester.h ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/histogram_tester.cc
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index 5ca3c2fe9e8dd6145f05741fdf6022be49e877e0..485f30f0eec1d2fe8c59a2ca1e8759d580012b2b 100644
--- a/base/test/histogram_tester.cc
+++ b/base/test/histogram_tester.cc
@@ -95,6 +95,31 @@ std::vector<Bucket> HistogramTester::GetAllSamples(
return samples;
}
+HistogramBase::Count HistogramTester::GetBucketCount(
+ const std::string& name,
+ HistogramBase::Sample sample) const {
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
+ EXPECT_NE(nullptr, histogram)
+ << "Histogram \"" << name << "\" does not exist.";
+ HistogramBase::Count count = 0;
+ if (histogram) {
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
+ GetBucketCountForSamples(name, sample, *samples, &count);
+ }
+ return count;
+}
+
+void HistogramTester::GetBucketCountForSamples(
+ const std::string& name,
+ HistogramBase::Sample sample,
+ const HistogramSamples& samples,
+ HistogramBase::Count* count) const {
+ *count = samples.GetCount(sample);
+ auto histogram_data = histograms_snapshot_.find(name);
+ if (histogram_data != histograms_snapshot_.end())
+ *count -= histogram_data->second->GetCount(sample);
+}
+
HistogramTester::CountsMap HistogramTester::GetTotalCountsForPrefix(
const std::string& prefix) const {
EXPECT_TRUE(prefix.find('.') != std::string::npos)
@@ -147,10 +172,8 @@ void HistogramTester::CheckBucketCount(const std::string& name,
HistogramBase::Sample sample,
HistogramBase::Count expected_count,
const HistogramSamples& samples) const {
- int actual_count = samples.GetCount(sample);
- auto histogram_data = histograms_snapshot_.find(name);
- if (histogram_data != histograms_snapshot_.end())
- actual_count -= histogram_data->second->GetCount(sample);
+ int actual_count;
+ GetBucketCountForSamples(name, sample, samples, &actual_count);
EXPECT_EQ(expected_count, actual_count)
<< "Histogram \"" << name
« no previous file with comments | « base/test/histogram_tester.h ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698