Commit 85d4d667 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Remove Chrome-specific code from QUIC's MockClock class.

A future CL will rename this to FakeClock.

Change-Id: I105d1d0278eb15eb0601fd40b45f738cd9cad7ff
Reviewed-on: https://chromium-review.googlesource.com/1163832
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580936}
parent 7370efa1
......@@ -13,6 +13,16 @@
namespace net {
namespace test {
namespace {
base::TimeTicks NowInTicks(const quic::MockClock& clock) {
base::TimeTicks ticks;
return ticks + base::TimeDelta::FromMicroseconds(
(clock.Now() - quic::QuicTime::Zero()).ToMicroseconds());
}
} // namespace
TestTaskRunner::TestTaskRunner(quic::MockClock* clock) : clock_(clock) {}
TestTaskRunner::~TestTaskRunner() {}
......@@ -21,7 +31,7 @@ bool TestTaskRunner::PostDelayedTask(const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
EXPECT_GE(delay, base::TimeDelta());
tasks_.push_back(PostedTask(from_here, std::move(task), clock_->NowInTicks(),
tasks_.push_back(PostedTask(from_here, std::move(task), NowInTicks(*clock_),
delay, base::TestPendingTask::NESTABLE));
return false;
}
......@@ -44,7 +54,7 @@ void TestTaskRunner::RunNextTask() {
std::vector<PostedTask>::iterator next = FindNextTask();
DCHECK(next != tasks_.end());
clock_->AdvanceTime(quic::QuicTime::Delta::FromMicroseconds(
(next->GetTimeToRun() - clock_->NowInTicks()).InMicroseconds()));
(next->GetTimeToRun() - NowInTicks(*clock_)).InMicroseconds()));
PostedTask task = std::move(*next);
tasks_.erase(next);
std::move(task.task).Run();
......
......@@ -26,10 +26,4 @@ QuicWallTime MockClock::WallNow() const {
return QuicWallTime::FromUNIXSeconds((now_ - QuicTime::Zero()).ToSeconds());
}
base::TimeTicks MockClock::NowInTicks() const {
base::TimeTicks ticks;
return ticks + base::TimeDelta::FromMicroseconds(
(now_ - QuicTime::Zero()).ToMicroseconds());
}
} // namespace quic
......@@ -5,10 +5,7 @@
#ifndef NET_THIRD_PARTY_QUIC_TEST_TOOLS_MOCK_CLOCK_H_
#define NET_THIRD_PARTY_QUIC_TEST_TOOLS_MOCK_CLOCK_H_
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "net/third_party/quic/core/quic_time.h"
#include "net/third_party/quic/platform/api/quic_clock.h"
namespace quic {
......@@ -28,9 +25,6 @@ class MockClock : public QuicClock {
// Advances the current time by |delta|, which may be negative.
void AdvanceTime(QuicTime::Delta delta);
// Returns the current time in ticks.
base::TimeTicks NowInTicks() const;
private:
QuicTime now_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment