diff options
author | lpromero@chromium.org <lpromero@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 17:46:47 +0000 |
---|---|---|
committer | lpromero@chromium.org <lpromero@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 17:46:47 +0000 |
commit | bbc2e4c6ab8afb95f5e63b7a02f8ef60c71dec9b (patch) | |
tree | 228ab5edfa0163c9c80daf33daa226b3d9fa6299 | |
parent | 473bdc43543599e19a749a530b839fac5f865e0c (diff) | |
download | chromium_src-bbc2e4c6ab8afb95f5e63b7a02f8ef60c71dec9b.zip chromium_src-bbc2e4c6ab8afb95f5e63b7a02f8ef60c71dec9b.tar.gz chromium_src-bbc2e4c6ab8afb95f5e63b7a02f8ef60c71dec9b.tar.bz2 |
Reland "Add a HistogramRecorder class and use cases."
This CL adds a utility class to streamline the task of testing that metrics have been updated as expected. Specifically, the HistogramRecorder class allows a client to obtain the differential value of a given histogram in the interval since the given HistogramRecorder instance was created.
This reverts commit b957026f43ef9464a8cdd5a240867c807b2281da.
BUG=232414
TBR=rsleevi, mark, groby, thakis
Review URL: https://codereview.chromium.org/19866004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242121 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base.gyp | 3 | ||||
-rw-r--r-- | base/metrics/statistics_recorder.h | 6 | ||||
-rw-r--r-- | base/test/histogram_recorder.cc | 52 | ||||
-rw-r--r-- | base/test/histogram_recorder.h | 44 | ||||
-rw-r--r-- | base/test/histogram_recorder_unittest.cc | 41 | ||||
-rw-r--r-- | chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc | 104 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm | 35 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_unittest.cc | 82 |
8 files changed, 205 insertions, 162 deletions
diff --git a/base/base.gyp b/base/base.gyp index 1c2e931..1bd8e53 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -640,6 +640,7 @@ 'template_util_unittest.cc', 'test/expectations/expectation_unittest.cc', 'test/expectations/parser_unittest.cc', + 'test/histogram_recorder_unittest.cc', 'test/test_reg_util_win_unittest.cc', 'test/trace_event_analyzer_unittest.cc', 'threading/non_thread_safe_unittest.cc', @@ -906,6 +907,8 @@ 'test/expectations/parser.h', 'test/gtest_xml_util.cc', 'test/gtest_xml_util.h', + 'test/histogram_recorder.cc', + 'test/histogram_recorder.h', 'test/launcher/test_launcher.cc', 'test/launcher/test_launcher.h', 'test/launcher/test_result.cc', diff --git a/base/metrics/statistics_recorder.h b/base/metrics/statistics_recorder.h index 0716e80..9cf1de7 100644 --- a/base/metrics/statistics_recorder.h +++ b/base/metrics/statistics_recorder.h @@ -70,9 +70,9 @@ class BASE_EXPORT StatisticsRecorder { static HistogramBase* FindHistogram(const std::string& name); // GetSnapshot copies some of the pointers to registered histograms into the - // caller supplied vector (Histograms). Only histograms with names matching - // query are returned. The query must be a substring of histogram name for its - // pointer to be copied. + // caller supplied vector (Histograms). Only histograms which have |query| as + // a substring are copied (an empty string will process all registered + // histograms). static void GetSnapshot(const std::string& query, Histograms* snapshot); private: diff --git a/base/test/histogram_recorder.cc b/base/test/histogram_recorder.cc new file mode 100644 index 0000000..ee852f7 --- /dev/null +++ b/base/test/histogram_recorder.cc @@ -0,0 +1,52 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/histogram_recorder.h" + +#include "base/metrics/histogram.h" +#include "base/metrics/statistics_recorder.h" +#include "base/stl_util.h" + +namespace base { + +// static +void HistogramRecorder::Initialize() { + // Ensure that StatisticsRecorder is initialized. + StatisticsRecorder::Initialize(); +} + +HistogramRecorder::HistogramRecorder() { + // Record any histogram data that exists when the object is created so it can + // be subtracted later. + StatisticsRecorder::Histograms histograms; + StatisticsRecorder::GetSnapshot("", &histograms); + for (size_t i = 0; i < histograms.size(); i++) { + original_samples_[histograms[i]->histogram_name()] = + histograms[i]->SnapshotSamples().release(); + } +} + +HistogramRecorder::~HistogramRecorder() { + STLDeleteValues(&original_samples_); +} + +// static +bool HistogramRecorder::IsActive() { + return StatisticsRecorder::IsActive(); +} + +scoped_ptr<HistogramSamples> + HistogramRecorder::GetHistogramSamplesSinceCreation( + const std::string& histogram_name) { + HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name); + if (!histogram) + return scoped_ptr<HistogramSamples>(); + scoped_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples()); + HistogramSamples* named_original_samples = original_samples_[histogram_name]; + if (named_original_samples) + named_samples->Subtract(*named_original_samples); + return named_samples.Pass(); +} + +} // namespace base diff --git a/base/test/histogram_recorder.h b/base/test/histogram_recorder.h new file mode 100644 index 0000000..f867b1e --- /dev/null +++ b/base/test/histogram_recorder.h @@ -0,0 +1,44 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TEST_HISTOGRAM_RECORDER_H_ +#define BASE_TEST_HISTOGRAM_RECORDER_H_ + +#include <map> + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "base/metrics/histogram_samples.h" + +namespace base { + +// This class acts as a differential reader for histogram samples, enabling +// tests to check that metrics were recorded as they should be. +class HistogramRecorder { + public: + // Initializes the HistogramRecorder system. + static void Initialize(); + HistogramRecorder(); + virtual ~HistogramRecorder(); + + // Returns whether the HistogramRecorder has been initialized. + static bool IsActive(); + + // Returns the histogram data accumulated since this instance was created. + // Returns NULL if no samples are available. + scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( + const std::string& histogram_name); + + private: + // Used to determine the histogram changes made during this instance's + // lifecycle. This isntance takes ownership of the samples, which are deleted + // when the instance is destroyed. + std::map<std::string, HistogramSamples*> original_samples_; + + DISALLOW_COPY_AND_ASSIGN(HistogramRecorder); +}; + +} // namespace base + +#endif // BASE_TEST_HISTOGRAM_RECORDER_H_ diff --git a/base/test/histogram_recorder_unittest.cc b/base/test/histogram_recorder_unittest.cc new file mode 100644 index 0000000..f4cdf49 --- /dev/null +++ b/base/test/histogram_recorder_unittest.cc @@ -0,0 +1,41 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/memory/scoped_ptr.h" +#include "base/metrics/histogram.h" +#include "base/metrics/histogram_samples.h" +#include "base/test/histogram_recorder.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { + +class HistogramRecorderTest : public testing::Test { + public: + static void SetUpTestCase() { + HistogramRecorder::Initialize(); + } +}; + +TEST_F(HistogramRecorderTest, Scope) { + // Record a histogram before the creation of the recorder. + UMA_HISTOGRAM_BOOLEAN("Test", true); + + HistogramRecorder recorder; + + // Verify that no histogram is recorded. + scoped_ptr<HistogramSamples> samples( + recorder.GetHistogramSamplesSinceCreation("Test")); + EXPECT_TRUE(samples); + EXPECT_EQ(0, samples->TotalCount()); + + // Record a histogram after the creation of the recorder. + UMA_HISTOGRAM_BOOLEAN("Test", true); + + // Verify that one histogram is recorded. + samples = recorder.GetHistogramSamplesSinceCreation("Test"); + EXPECT_TRUE(samples); + EXPECT_EQ(1, samples->TotalCount()); +} + +} // namespace base diff --git a/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc b/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc index ab7348a..f702723 100644 --- a/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc +++ b/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc @@ -7,10 +7,9 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" -#include "base/metrics/statistics_recorder.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/histogram_recorder.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(OS_WIN) @@ -18,55 +17,51 @@ #include "base/win/windows_version.h" #endif -using base::HistogramBase; -using base::HistogramSamples; -using base::StatisticsRecorder; - class SpellcheckHostMetricsTest : public testing::Test { public: SpellcheckHostMetricsTest() : loop_(base::MessageLoop::TYPE_DEFAULT) { } + static void SetUpTestCase() { + base::HistogramRecorder::Initialize(); + } + virtual void SetUp() OVERRIDE { - base::StatisticsRecorder::Initialize(); + ResetHistogramRecorder(); metrics_.reset(new SpellCheckHostMetrics); } + void ResetHistogramRecorder() { + histogram_recorder_.reset(new base::HistogramRecorder()); + } + SpellCheckHostMetrics* metrics() { return metrics_.get(); } void RecordWordCountsForTesting() { metrics_->RecordWordCounts(); } + protected: + scoped_ptr<base::HistogramRecorder> histogram_recorder_; + private: base::MessageLoop loop_; scoped_ptr<SpellCheckHostMetrics> metrics_; }; TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) { - scoped_ptr<HistogramSamples> baseline; - HistogramBase* histogram = - StatisticsRecorder::FindHistogram("SpellCheck.Enabled"); - if (histogram) - baseline = histogram->SnapshotSamples(); + const char kMetricName[] = "SpellCheck.Enabled"; metrics()->RecordEnabledStats(false); - histogram = - StatisticsRecorder::FindHistogram("SpellCheck.Enabled"); - ASSERT_TRUE(histogram != NULL); - scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples()); - if (baseline.get()) - samples->Subtract(*baseline); + scoped_ptr<base::HistogramSamples> samples( + histogram_recorder_->GetHistogramSamplesSinceCreation(kMetricName)); EXPECT_EQ(1, samples->GetCount(0)); EXPECT_EQ(0, samples->GetCount(1)); - baseline.reset(samples.release()); + ResetHistogramRecorder(); metrics()->RecordEnabledStats(true); - histogram = - StatisticsRecorder::FindHistogram("SpellCheck.Enabled"); - ASSERT_TRUE(histogram != NULL); - samples = histogram->SnapshotSamples(); - samples->Subtract(*baseline); + samples = + histogram_recorder_->GetHistogramSamplesSinceCreation(kMetricName); EXPECT_EQ(0, samples->GetCount(0)); EXPECT_EQ(1, samples->GetCount(1)); } @@ -81,21 +76,16 @@ TEST_F(SpellcheckHostMetricsTest, CustomWordStats) { // Determine if test failures are due the statistics recorder not being // available or because the histogram just isn't there: crbug.com/230534. - EXPECT_TRUE(StatisticsRecorder::IsActive()); + EXPECT_TRUE(base::HistogramRecorder::IsActive()); - HistogramBase* histogram = - StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); - ASSERT_TRUE(histogram != NULL); - scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples(); + ResetHistogramRecorder(); SpellCheckHostMetrics::RecordCustomWordCountStats(23); - histogram = - StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); - ASSERT_TRUE(histogram != NULL); - scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); - samples->Subtract(*baseline); - EXPECT_EQ(23,samples->sum()); + scoped_ptr<base::HistogramSamples> samples( + histogram_recorder_->GetHistogramSamplesSinceCreation( + "SpellCheck.CustomWords")); + EXPECT_EQ(23, samples->sum()); } TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) { @@ -113,59 +103,37 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) { metrics()->RecordCheckedWordStats(ASCIIToUTF16("test"), false); RecordWordCountsForTesting(); - // Get baselines for all affected histograms. - scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)]; - for (size_t i = 0; i < arraysize(histogramName); ++i) { - HistogramBase* histogram = - StatisticsRecorder::FindHistogram(histogramName[i]); - if (histogram) - baselines[i] = histogram->SnapshotSamples(); - } + // Restart the recorder. + ResetHistogramRecorder(); // Nothing changed, so this invocation should not affect any histograms. RecordWordCountsForTesting(); // Get samples for all affected histograms. - scoped_ptr<HistogramSamples> samples[arraysize(histogramName)]; + scoped_ptr<base::HistogramSamples> samples; for (size_t i = 0; i < arraysize(histogramName); ++i) { - HistogramBase* histogram = - StatisticsRecorder::FindHistogram(histogramName[i]); - ASSERT_TRUE(histogram != NULL); - samples[i] = histogram->SnapshotSamples(); - if (baselines[i].get()) - samples[i]->Subtract(*baselines[i]); - - EXPECT_EQ(0, samples[i]->TotalCount()); + samples = histogram_recorder_->GetHistogramSamplesSinceCreation( + histogramName[i]); + EXPECT_EQ(0, samples->TotalCount()); } } TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) { const char kMetricName[] = "SpellCheck.SpellingService.Enabled"; - scoped_ptr<HistogramSamples> baseline; - HistogramBase* histogram = StatisticsRecorder::FindHistogram(kMetricName); - if (histogram) - baseline = histogram->SnapshotSamples(); metrics()->RecordSpellingServiceStats(false); - histogram = - StatisticsRecorder::FindHistogram(kMetricName); - ASSERT_TRUE(histogram != NULL); - scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples()); - if (baseline.get()) - samples->Subtract(*baseline); + scoped_ptr<base::HistogramSamples> samples( + histogram_recorder_->GetHistogramSamplesSinceCreation(kMetricName)); EXPECT_EQ(1, samples->GetCount(0)); EXPECT_EQ(0, samples->GetCount(1)); - baseline.reset(samples.release()); + ResetHistogramRecorder(); metrics()->RecordSpellingServiceStats(true); - histogram = - StatisticsRecorder::FindHistogram(kMetricName); - ASSERT_TRUE(histogram != NULL); - samples = histogram->SnapshotSamples(); - samples->Subtract(*baseline); + samples = + histogram_recorder_->GetHistogramSamplesSinceCreation(kMetricName); EXPECT_EQ(0, samples->GetCount(0)); EXPECT_EQ(1, samples->GetCount(1)); } diff --git a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm index c3211714..b9af977 100644 --- a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm @@ -5,19 +5,14 @@ #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h" #include "base/logging.h" -#include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" -#include "base/metrics/statistics_recorder.h" #include "base/strings/sys_string_conversions.h" +#include "base/test/histogram_recorder.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "components/autofill/core/browser/password_generator.h" #include "components/autofill/core/common/password_form.h" #include "testing/gtest_mac.h" -using base::HistogramBase; -using base::HistogramSamples; -using base::StatisticsRecorder; - const char kHistogramName[] = "PasswordGeneration.UserActions"; class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { @@ -26,7 +21,7 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { : controller_(nil) {} static void SetUpTestCase() { - StatisticsRecorder::Initialize(); + base::HistogramRecorder::Initialize(); } virtual void SetUp() { @@ -34,10 +29,7 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { generator_.reset(new autofill::PasswordGenerator(20)); - HistogramBase* histogram = - StatisticsRecorder::FindHistogram(kHistogramName); - if (histogram) - original_ = histogram->SnapshotSamples(); + histogram_recorder_.reset(new base::HistogramRecorder()); SetUpController(); } @@ -65,26 +57,16 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { controller_ = nil; } - HistogramSamples* GetHistogramSamples() { - HistogramBase* histogram = - StatisticsRecorder::FindHistogram(kHistogramName); - if (histogram) { - current_ = histogram->SnapshotSamples(); - if (original_.get()) - current_->Subtract(*original_.get()); - } - return current_.get(); + scoped_ptr<base::HistogramSamples> GetHistogramSamples() { + return histogram_recorder_->GetHistogramSamplesSinceCreation( + kHistogramName).Pass(); } protected: // Weak. PasswordGenerationBubbleController* controller_; - // Used to determine the histogram changes made just for this specific - // test run. - scoped_ptr<HistogramSamples> original_; - - scoped_ptr<HistogramSamples> current_; + scoped_ptr<base::HistogramRecorder> histogram_recorder_; scoped_ptr<autofill::PasswordGenerator> generator_; }; @@ -112,7 +94,7 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) { // Do nothing. CloseController(); - HistogramSamples* samples = GetHistogramSamples(); + scoped_ptr<base::HistogramSamples> samples(GetHistogramSamples()); EXPECT_EQ( 1, samples->GetCount(autofill::password_generation::IGNORE_FEATURE)); @@ -160,5 +142,4 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) { 1, samples->GetCount( autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD)); - } diff --git a/net/url_request/url_request_throttler_unittest.cc b/net/url_request/url_request_throttler_unittest.cc index b964b10..52b3a0a 100644 --- a/net/url_request/url_request_throttler_unittest.cc +++ b/net/url_request/url_request_throttler_unittest.cc @@ -5,13 +5,12 @@ #include "net/url_request/url_request_throttler_manager.h" #include "base/memory/scoped_ptr.h" -#include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" -#include "base/metrics/statistics_recorder.h" #include "base/pickle.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" +#include "base/test/histogram_recorder.h" #include "base/time/time.h" #include "net/base/load_flags.h" #include "net/base/request_priority.h" @@ -29,10 +28,7 @@ namespace net { namespace { -using base::Histogram; -using base::HistogramBase; -using base::HistogramSamples; -using base::StatisticsRecorder; +const char kRequestThrottledHistogramName[] = "Throttling.RequestThrottled"; class MockURLRequestThrottlerEntry : public URLRequestThrottlerEntry { public: @@ -176,32 +172,22 @@ class URLRequestThrottlerEntryTest : public testing::Test { URLRequestThrottlerEntryTest() : request_(GURL(), DEFAULT_PRIORITY, NULL, &context_) {} - virtual void SetUp(); - virtual void TearDown(); + static void SetUpTestCase() { + base::HistogramRecorder::Initialize(); + } - // After calling this function, histogram snapshots in |samples_| contain - // only the delta caused by the test case currently running. - void CalculateHistogramDeltas(); + virtual void SetUp(); TimeTicks now_; MockURLRequestThrottlerManager manager_; // Dummy object, not used. scoped_refptr<MockURLRequestThrottlerEntry> entry_; - std::map<std::string, HistogramSamples*> original_samples_; - std::map<std::string, HistogramSamples*> samples_; + scoped_ptr<base::HistogramRecorder> histogram_recorder_; TestURLRequestContext context_; TestURLRequest request_; }; -// List of all histograms we care about in these unit tests. -const char* kHistogramNames[] = { - "Throttling.FailureCountAtSuccess", - "Throttling.PerceivedDowntime", - "Throttling.RequestThrottled", - "Throttling.SiteOptedOut", -}; - void URLRequestThrottlerEntryTest::SetUp() { request_.SetLoadFlags(0); @@ -209,43 +195,7 @@ void URLRequestThrottlerEntryTest::SetUp() { entry_ = new MockURLRequestThrottlerEntry(&manager_); entry_->ResetToBlank(now_); - for (size_t i = 0; i < arraysize(kHistogramNames); ++i) { - // Must retrieve original samples for each histogram for comparison - // as other tests may affect them. - const char* name = kHistogramNames[i]; - HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); - if (histogram) { - original_samples_[name] = histogram->SnapshotSamples().release(); - } else { - original_samples_[name] = NULL; - } - } -} - -void URLRequestThrottlerEntryTest::TearDown() { - STLDeleteValues(&original_samples_); - STLDeleteValues(&samples_); -} - -void URLRequestThrottlerEntryTest::CalculateHistogramDeltas() { - for (size_t i = 0; i < arraysize(kHistogramNames); ++i) { - const char* name = kHistogramNames[i]; - HistogramSamples* original = original_samples_[name]; - - HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); - if (histogram) { - ASSERT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); - - scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples()); - if (original) - samples->Subtract(*original); - samples_[name] = samples.release(); - } - } - - // Ensure we don't accidentally use the originals in our tests. - STLDeleteValues(&original_samples_); - original_samples_.clear(); + histogram_recorder_.reset(new base::HistogramRecorder()); } std::ostream& operator<<(std::ostream& out, const base::TimeTicks& time) { @@ -273,9 +223,11 @@ TEST_F(URLRequestThrottlerEntryTest, InterfaceDuringExponentialBackoff) { request_.SetLoadFlags(LOAD_MAYBE_USER_GESTURE); EXPECT_FALSE(entry_->ShouldRejectRequest(request_)); - CalculateHistogramDeltas(); - ASSERT_EQ(1, samples_["Throttling.RequestThrottled"]->GetCount(0)); - ASSERT_EQ(1, samples_["Throttling.RequestThrottled"]->GetCount(1)); + scoped_ptr<base::HistogramSamples> samples( + histogram_recorder_->GetHistogramSamplesSinceCreation( + kRequestThrottledHistogramName)); + ASSERT_EQ(1, samples->GetCount(0)); + ASSERT_EQ(1, samples->GetCount(1)); } TEST_F(URLRequestThrottlerEntryTest, InterfaceNotDuringExponentialBackoff) { @@ -285,9 +237,11 @@ TEST_F(URLRequestThrottlerEntryTest, InterfaceNotDuringExponentialBackoff) { entry_->fake_time_now_ - TimeDelta::FromMilliseconds(1)); EXPECT_FALSE(entry_->ShouldRejectRequest(request_)); - CalculateHistogramDeltas(); - ASSERT_EQ(2, samples_["Throttling.RequestThrottled"]->GetCount(0)); - ASSERT_EQ(0, samples_["Throttling.RequestThrottled"]->GetCount(1)); + scoped_ptr<base::HistogramSamples> samples( + histogram_recorder_->GetHistogramSamplesSinceCreation( + kRequestThrottledHistogramName)); + ASSERT_EQ(2, samples->GetCount(0)); + ASSERT_EQ(0, samples->GetCount(1)); } TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateFailure) { |