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

Unified Diff: third_party/WebKit/Source/platform/TimerTest.cpp

Issue 1727103002: Revert of Per WebViewScheduler virtual time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: third_party/WebKit/Source/platform/TimerTest.cpp
diff --git a/third_party/WebKit/Source/platform/TimerTest.cpp b/third_party/WebKit/Source/platform/TimerTest.cpp
index 61cc4c0a8ad83550408cd52e4efd587516c65ca3..4284a625be935ceb275490158838a1b5d4dd24c1 100644
--- a/third_party/WebKit/Source/platform/TimerTest.cpp
+++ b/third_party/WebKit/Source/platform/TimerTest.cpp
@@ -19,6 +19,11 @@
namespace {
double gCurrentTimeSecs = 0.0;
+double currentTime()
+{
+ return gCurrentTimeSecs;
+}
+
// This class exists because gcc doesn't know how to move an OwnPtr.
class RefCountedTaskContainer : public RefCounted<RefCountedTaskContainer> {
public:
@@ -39,10 +44,8 @@
public:
DelayedTask(WebTaskRunner::Task* task, double delaySeconds)
: m_task(adoptRef(new RefCountedTaskContainer(task)))
- , m_runTimeSeconds(gCurrentTimeSecs + delaySeconds)
- , m_delaySeconds(delaySeconds)
- {
- }
+ , m_runTimeSeconds(monotonicallyIncreasingTime() + delaySeconds)
+ , m_delaySeconds(delaySeconds) { }
bool operator<(const DelayedTask& other) const
{
@@ -89,17 +92,6 @@
{
ASSERT_NOT_REACHED();
return nullptr;
- }
-
- double virtualTimeSeconds() const override
- {
- ASSERT_NOT_REACHED();
- return 0.0;
- }
-
- double monotonicallyIncreasingVirtualTimeSeconds() const override
- {
- return gCurrentTimeSecs;
}
std::priority_queue<DelayedTask>* m_timerTasks; // NOT OWNED
@@ -288,19 +280,26 @@
public:
void SetUp() override
{
+ m_originalTimeFunction = setTimeFunctionsForTesting(currentTime);
+
m_runTimes.clear();
gCurrentTimeSecs = 10.0;
m_startTime = gCurrentTimeSecs;
}
+ void TearDown() override
+ {
+ setTimeFunctionsForTesting(m_originalTimeFunction);
+ }
+
void countingTask(Timer<TimerTest>*)
{
- m_runTimes.append(gCurrentTimeSecs);
+ m_runTimes.append(monotonicallyIncreasingTime());
}
void recordNextFireTimeTask(Timer<TimerTest>* timer)
{
- m_nextFireTimes.append(gCurrentTimeSecs + timer->nextFireInterval());
+ m_nextFireTimes.append(monotonicallyIncreasingTime() + timer->nextFireInterval());
}
void advanceTimeBy(double timeSecs)
@@ -340,6 +339,7 @@
private:
TimerTestPlatform m_platform;
+ TimeFunction m_originalTimeFunction;
};
TEST_F(TimerTest, StartOneShot_Zero)
@@ -449,7 +449,7 @@
runUntilIdle();
EXPECT_FALSE(m_runTimes.size());
- double secondPostTime = gCurrentTimeSecs;
+ double secondPostTime = monotonicallyIncreasingTime();
timer.startOneShot(10, BLINK_FROM_HERE);
ASSERT(hasOneTimerTask());

Powered by Google App Engine
This is Rietveld 408576698