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..048ac02f7d17fb541d7499f927f086e64e0692d9 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(); |
dcheng
2016/07/28 13:09:51
This was only used by three subclasses: Suspendabl
haraken
2016/07/28 14:44:46
I believe that SuspendableTImer was intentionally
haraken
2016/07/28 17:38:15
So, ignore this comment.
dcheng
2016/07/29 02:23:18
!!! I made a mistake. I changed SuspendableTimer t
|
explicit TimerBase(WebTaskRunner*); |
virtual ~TimerBase(); |
@@ -77,7 +76,8 @@ public: |
}; |
protected: |
- static WebTaskRunner* UnthrottledWebTaskRunner(); |
+ static WebTaskRunner* getTimerTaskRunner(); |
+ static WebTaskRunner* getDefaultTaskRunner(); |
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; |
dcheng
2016/07/28 13:09:51
I switched these to using type aliases, because it
|
+ |
+ ~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::getDefaultTaskRunner(), timerFiredClass, timerFiredFunction) |
{ |
} |
}; |