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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h

Issue 1076853003: Refactor net::BackoffEntry to not require subclassing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ConnectionFactoryImplTest Created 5 years, 8 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h
index 105ac2a237c419f9ce66d44ce1ed100949b09fc8..8d2cf29f5e3596405e44e40894f95012ca50d3d4 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h
@@ -11,6 +11,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
+#include "base/time/clock.h"
+#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h"
@@ -114,15 +116,15 @@ class TestDataReductionProxyConfigServiceClient
private:
// A clock which returns a fixed value in both base::Time and base::TimeTicks.
- class TestTickClock {
+ class TestTickClock : public base::Clock, public base::TickClock {
public:
TestTickClock(const base::Time& initial_time);
- // Returns the current base::TimeTicks
- base::TimeTicks NowTicks() const;
+ // base::TickClock implementation.
+ base::TimeTicks NowTicks() override;
- // Returns the current base::Time
- base::Time Now() const;
+ // base::Clock implementation.
+ base::Time Now() override;
// Sets the current time.
void SetTime(const base::Time& time);
@@ -131,23 +133,8 @@ class TestDataReductionProxyConfigServiceClient
base::Time time_;
};
- // A net::BackoffEntry which uses an injected base::TickClock to control
- // the backoff expiration time.
- class TestBackoffEntry : public net::BackoffEntry {
- public:
- TestBackoffEntry(const BackoffEntry::Policy* const policy,
- const TestTickClock* tick_clock);
-
- protected:
- // Override of net::BackoffEntry.
- base::TimeTicks ImplGetTimeNow() const override;
-
- private:
- const TestTickClock* tick_clock_;
- };
-
- TestTickClock tick_clock_;
- TestBackoffEntry test_backoff_entry_;
+ mutable TestTickClock tick_clock_;
mmenke 2015/04/10 15:50:43 Why does this have to be mutable?
johnme 2015/04/10 16:23:36 It was because base::Clock::Now is non-const, henc
mmenke 2015/04/10 16:26:37 I'd go ahead and make DataReductionProxyConfigServ
+ net::BackoffEntry test_backoff_entry_;
};
// Test version of |DataReductionProxyService|, which permits mocking of various

Powered by Google App Engine
This is Rietveld 408576698