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

Unified Diff: net/url_request/url_request_throttler_simulation_unittest.cc

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 | « net/base/backoff_entry_unittest.cc ('k') | net/url_request/url_request_throttler_test_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_throttler_simulation_unittest.cc
diff --git a/net/url_request/url_request_throttler_simulation_unittest.cc b/net/url_request/url_request_throttler_simulation_unittest.cc
index 39991595f56d4b8d16c37a24af5b723d38e61c7f..80734ae29cc66582f587ea6b18fd86ffdca3e8d6 100644
--- a/net/url_request/url_request_throttler_simulation_unittest.cc
+++ b/net/url_request/url_request_throttler_simulation_unittest.cc
@@ -303,31 +303,26 @@ class MockURLRequestThrottlerEntry : public URLRequestThrottlerEntry {
public:
explicit MockURLRequestThrottlerEntry(URLRequestThrottlerManager* manager)
: URLRequestThrottlerEntry(manager, std::string()),
- mock_backoff_entry_(&backoff_policy_) {}
+ backoff_entry_(&backoff_policy_, &fake_clock_) {}
const BackoffEntry* GetBackoffEntry() const override {
- return &mock_backoff_entry_;
+ return &backoff_entry_;
}
- BackoffEntry* GetBackoffEntry() override { return &mock_backoff_entry_; }
+ BackoffEntry* GetBackoffEntry() override { return &backoff_entry_; }
- TimeTicks ImplGetTimeNow() const override { return fake_now_; }
+ TimeTicks ImplGetTimeNow() const override { return fake_clock_.NowTicks(); }
void SetFakeNow(const TimeTicks& fake_time) {
- fake_now_ = fake_time;
- mock_backoff_entry_.set_fake_now(fake_time);
- }
-
- TimeTicks fake_now() const {
- return fake_now_;
+ fake_clock_.set_now(fake_time);
}
protected:
~MockURLRequestThrottlerEntry() override {}
private:
- TimeTicks fake_now_;
- MockBackoffEntry mock_backoff_entry_;
+ mutable TestTickClock fake_clock_;
+ BackoffEntry backoff_entry_;
};
// Registry of results for a class of |Requester| objects (e.g. attackers vs.
@@ -426,7 +421,7 @@ class Requester : public DiscreteTimeSimulation::Actor {
effective_delay += current_jitter;
}
- if (throttler_entry_->fake_now() - time_of_last_attempt_ >
+ if (throttler_entry_->ImplGetTimeNow() - time_of_last_attempt_ >
effective_delay) {
if (!throttler_entry_->ShouldRejectRequest(
server_->mock_request(),
@@ -441,10 +436,10 @@ class Requester : public DiscreteTimeSimulation::Actor {
if (last_attempt_was_failure_) {
last_downtime_duration_ =
- throttler_entry_->fake_now() - time_of_last_success_;
+ throttler_entry_->ImplGetTimeNow() - time_of_last_success_;
}
- time_of_last_success_ = throttler_entry_->fake_now();
+ time_of_last_success_ = throttler_entry_->ImplGetTimeNow();
last_attempt_was_failure_ = false;
} else {
if (results_)
@@ -457,7 +452,7 @@ class Requester : public DiscreteTimeSimulation::Actor {
last_attempt_was_failure_ = true;
}
- time_of_last_attempt_ = throttler_entry_->fake_now();
+ time_of_last_attempt_ = throttler_entry_->ImplGetTimeNow();
}
}
« no previous file with comments | « net/base/backoff_entry_unittest.cc ('k') | net/url_request/url_request_throttler_test_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698