diff options
author | johnme <johnme@chromium.org> | 2015-04-20 10:06:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-20 17:06:21 +0000 |
commit | dce40c39e0d44436283fbc43fa9b708153dd04e6 (patch) | |
tree | c680a23267bba048f057cddf9d04a2cb2e099e61 /google_apis | |
parent | 32be343ac9b22aa66d645aed4c701f127072aaab (diff) | |
download | chromium_src-dce40c39e0d44436283fbc43fa9b708153dd04e6.zip chromium_src-dce40c39e0d44436283fbc43fa9b708153dd04e6.tar.gz chromium_src-dce40c39e0d44436283fbc43fa9b708153dd04e6.tar.bz2 |
Refactor net::BackoffEntry to not require subclassing
Before this patch, net::BackoffEntry had a virtual ImplGetTimeNow method
that tests etc would override to change what time is considered "now".
As suggested by rsleevi in https://codereview.chromium.org/1023473003,
this patch removes that method, and instead makes net::BackoffEntry
accept a base::TickClock in the constructor, to allow overriding the
time without subclassing.
(this will allow future changes to net::BackoffEntry without the
fragile base class problem)
Accordingly, I've removed all subclasses of BackoffEntry, and made them
pass TickClocks instead; in most cases this has been a nice
simplification.
BUG=465399
TBR=stevenjb@chromium.org
Review URL: https://codereview.chromium.org/1076853003
Cr-Commit-Position: refs/heads/master@{#325865}
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gcm/engine/connection_factory_impl_unittest.cc | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/google_apis/gcm/engine/connection_factory_impl_unittest.cc b/google_apis/gcm/engine/connection_factory_impl_unittest.cc index ed23da9..4c0e127 100644 --- a/google_apis/gcm/engine/connection_factory_impl_unittest.cc +++ b/google_apis/gcm/engine/connection_factory_impl_unittest.cc @@ -80,28 +80,6 @@ void ReadContinuation( void WriteContinuation() { } -class TestBackoffEntry : public net::BackoffEntry { - public: - explicit TestBackoffEntry(base::SimpleTestTickClock* tick_clock); - ~TestBackoffEntry() override; - - base::TimeTicks ImplGetTimeNow() const override; - - private: - base::SimpleTestTickClock* tick_clock_; -}; - -TestBackoffEntry::TestBackoffEntry(base::SimpleTestTickClock* tick_clock) - : BackoffEntry(&kTestBackoffPolicy), - tick_clock_(tick_clock) { -} - -TestBackoffEntry::~TestBackoffEntry() {} - -base::TimeTicks TestBackoffEntry::ImplGetTimeNow() const { - return tick_clock_->NowTicks(); -} - // A connection factory that stubs out network requests and overrides the // backoff policy. class TestConnectionFactoryImpl : public ConnectionFactoryImpl { @@ -213,7 +191,8 @@ void TestConnectionFactoryImpl::InitHandler() { scoped_ptr<net::BackoffEntry> TestConnectionFactoryImpl::CreateBackoffEntry( const net::BackoffEntry::Policy* const policy) { - return scoped_ptr<net::BackoffEntry>(new TestBackoffEntry(&tick_clock_)); + return make_scoped_ptr(new net::BackoffEntry(&kTestBackoffPolicy, + &tick_clock_)); } scoped_ptr<ConnectionHandler> |