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

Unified Diff: components/domain_reliability/util.h

Issue 1076853003: Refactor net::BackoffEntry to not require subclassing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address pneubeck's review comments 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
« no previous file with comments | « components/domain_reliability/scheduler.cc ('k') | components/domain_reliability/util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/util.h
diff --git a/components/domain_reliability/util.h b/components/domain_reliability/util.h
index 4256b059cbd0a4e41d76051b3c02f072ca67622a..832e2fc4196351f92567577e2a4017d85d781ce8 100644
--- a/components/domain_reliability/util.h
+++ b/components/domain_reliability/util.h
@@ -10,11 +10,12 @@
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/time/clock.h"
+#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "base/tracked_objects.h"
#include "components/domain_reliability/domain_reliability_export.h"
#include "components/domain_reliability/uploader.h"
-#include "net/base/backoff_entry.h"
#include "net/http/http_response_info.h"
#include "net/url_request/url_request_status.h"
@@ -51,7 +52,8 @@ void GetUploadResultFromResponseDetails(
// Mockable wrapper around TimeTicks::Now and Timer. Mock version is in
// test_util.h.
// TODO(ttuttle): Rename to Time{Provider,Source,?}.
-class DOMAIN_RELIABILITY_EXPORT MockableTime {
+class DOMAIN_RELIABILITY_EXPORT MockableTime : public base::Clock,
+ public base::TickClock {
public:
// Mockable wrapper around (a subset of) base::Timer.
class DOMAIN_RELIABILITY_EXPORT Timer {
@@ -68,12 +70,13 @@ class DOMAIN_RELIABILITY_EXPORT MockableTime {
Timer();
};
- virtual ~MockableTime();
+ ~MockableTime() override;
+
+ // Clock impl; returns base::Time::Now() or a mocked version thereof.
+ base::Time Now() override = 0;
+ // TickClock impl; returns base::TimeTicks::Now() or a mocked version thereof.
+ base::TimeTicks NowTicks() override = 0;
- // Returns base::Time::Now() or a mocked version thereof.
- virtual base::Time Now() = 0;
- // Returns base::TimeTicks::Now() or a mocked version thereof.
- virtual base::TimeTicks NowTicks() = 0;
// Returns a new Timer, or a mocked version thereof.
virtual scoped_ptr<MockableTime::Timer> CreateTimer() = 0;
@@ -98,21 +101,6 @@ class DOMAIN_RELIABILITY_EXPORT ActualTime : public MockableTime {
scoped_ptr<MockableTime::Timer> CreateTimer() override;
};
-// A subclass of BackoffEntry that uses a MockableTime to keep track of time.
-class MockableTimeBackoffEntry : public net::BackoffEntry {
- public:
- MockableTimeBackoffEntry(const net::BackoffEntry::Policy* const policy,
- MockableTime* time);
-
- ~MockableTimeBackoffEntry() override;
-
- protected:
- base::TimeTicks ImplGetTimeNow() const override;
-
- private:
- MockableTime* time_;
-};
-
} // namespace domain_reliability
#endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_
« no previous file with comments | « components/domain_reliability/scheduler.cc ('k') | components/domain_reliability/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698