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

Unified Diff: third_party/WebKit/Source/platform/Timer.h

Issue 2191533003: Refactor Timer classes in preparation for landing FrameTimers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More build fixes Created 4 years, 5 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/Timer.h
diff --git a/third_party/WebKit/Source/platform/Timer.h b/third_party/WebKit/Source/platform/Timer.h
index 8245b3adbf1a499f5fbfa49ee5816444badc9fcf..7027d26f4f5f79e11cc2aef637d7329f45c28788 100644
--- a/third_party/WebKit/Source/platform/Timer.h
+++ b/third_party/WebKit/Source/platform/Timer.h
@@ -44,7 +44,6 @@ namespace blink {
class PLATFORM_EXPORT TimerBase {
WTF_MAKE_NONCOPYABLE(TimerBase);
public:
- TimerBase();
explicit TimerBase(WebTaskRunner*);
virtual ~TimerBase();
@@ -77,7 +76,8 @@ public:
};
protected:
- static WebTaskRunner* UnthrottledWebTaskRunner();
+ static WebTaskRunner* getTimerTaskRunner();
+ static WebTaskRunner* getUnthrottledTaskRunner();
private:
virtual void fired() = 0;
@@ -155,23 +155,16 @@ public:
};
template <typename TimerFiredClass>
-class Timer : public TimerBase {
+class TaskRunnerTimer : public TimerBase {
public:
- using TimerFiredFunction = void (TimerFiredClass::*)(Timer<TimerFiredClass>*);
+ using TimerFiredFunction = void (TimerFiredClass::*)(TimerBase*);
- // TODO(dcheng): Consider removing this overload once all timers are using the
- // appropriate task runner. https://crbug.com/624694
- Timer(TimerFiredClass* o, TimerFiredFunction f)
- : m_object(o), m_function(f)
- {
- }
-
- Timer(TimerFiredClass* o, TimerFiredFunction f, WebTaskRunner* webTaskRunner)
+ TaskRunnerTimer(WebTaskRunner* webTaskRunner, TimerFiredClass* o, TimerFiredFunction f)
: TimerBase(webTaskRunner), m_object(o), m_function(f)
{
}
- ~Timer() override { }
+ ~TaskRunnerTimer() override { }
protected:
void fired() override
@@ -197,17 +190,33 @@ private:
TimerFiredFunction m_function;
};
+// TODO(dcheng): Consider removing this overload once all timers are using the
+// appropriate task runner. https://crbug.com/624694
+template <typename TimerFiredClass>
+class Timer : public TaskRunnerTimer<TimerFiredClass> {
+public:
+ using TimerFiredFunction = typename TaskRunnerTimer<TimerFiredClass>::TimerFiredFunction;
+
+ ~Timer() override { }
+
+ Timer(TimerFiredClass* timerFiredClass, TimerFiredFunction timerFiredFunction)
+ : TaskRunnerTimer<TimerFiredClass>(TimerBase::getTimerTaskRunner(), timerFiredClass, timerFiredFunction)
+ {
+ }
+};
+
+
// This subclass of Timer posts its tasks on the current thread's default task runner.
// Tasks posted on there are not throttled when the tab is in the background.
template <typename TimerFiredClass>
-class UnthrottledTimer : public Timer<TimerFiredClass> {
+class UnthrottledThreadTimer : public TaskRunnerTimer<TimerFiredClass> {
public:
- using TimerFiredFunction = void (TimerFiredClass::*)(Timer<TimerFiredClass>*);
+ using TimerFiredFunction = typename TaskRunnerTimer<TimerFiredClass>::TimerFiredFunction;
- ~UnthrottledTimer() override { }
+ ~UnthrottledThreadTimer() override { }
- UnthrottledTimer(TimerFiredClass* timerFiredClass, TimerFiredFunction timerFiredFunction)
- : Timer<TimerFiredClass>(timerFiredClass, timerFiredFunction, TimerBase::UnthrottledWebTaskRunner())
+ UnthrottledThreadTimer(TimerFiredClass* timerFiredClass, TimerFiredFunction timerFiredFunction)
+ : TaskRunnerTimer<TimerFiredClass>(TimerBase::getUnthrottledTaskRunner(), timerFiredClass, timerFiredFunction)
{
}
};
« no previous file with comments | « third_party/WebKit/Source/platform/AsyncMethodRunner.h ('k') | third_party/WebKit/Source/platform/Timer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698