Index: Source/platform/Timer.h |
diff --git a/Source/platform/Timer.h b/Source/platform/Timer.h |
index 67d815f1bcf7a4a02568cc0488f0bd637cf62fdb..966aa5d2b8c8939cb1204e9de36325afc966a3ea 100644 |
--- a/Source/platform/Timer.h |
+++ b/Source/platform/Timer.h |
@@ -27,11 +27,11 @@ |
#define Timer_h |
#include "platform/PlatformExport.h" |
+#include "platform/TimerHeapEntry.h" |
#include "platform/heap/Handle.h" |
#include "public/platform/WebTraceLocation.h" |
#include "wtf/Noncopyable.h" |
#include "wtf/Threading.h" |
-#include "wtf/Vector.h" |
namespace blink { |
@@ -43,8 +43,9 @@ public: |
TimerBase(); |
virtual ~TimerBase(); |
- void start(double nextFireInterval, double repeatInterval, const WebTraceLocation&); |
+ static void fireTimersInNestedEventLoop(); |
+ void start(double nextFireInterval, double repeatInterval, const WebTraceLocation&); |
void startRepeating(double repeatInterval, const WebTraceLocation& caller) |
{ |
start(repeatInterval, repeatInterval, caller); |
@@ -53,64 +54,52 @@ public: |
{ |
start(interval, 0, caller); |
} |
- |
void stop(); |
+ |
bool isActive() const; |
+ |
+ // FIXME: ThreadTimers dabbles with nextFireTime, but other timers |
+ // (eg suspendableTimer) manipulate it too; why is it safe? |
+ double nextFireTime() const { return m_heapEntry.value(); } |
+ void setNextFireTime(double); |
+ |
+ const TimerHeapEntry& heapEntry() const { return m_heapEntry; } |
+ TimerHeapEntry& heapEntry() { return m_heapEntry; } |
const WebTraceLocation& location() const { return m_location; } |
+ double repeatInterval() const { return m_repeatInterval; } |
+ // FIXME: This is only used by SMILTimeContainer; the API it |
+ // really wants is something like "can I get this sooner by |
+ // rescheduling it" or something like that. |
double nextFireInterval() const; |
+ |
+ // FIXME: This is only used by SuspendableTimer. Push it down to |
+ // that type. |
double nextUnalignedFireInterval() const; |
- double repeatInterval() const { return m_repeatInterval; } |
+ // FIXME: This is only used by DOMTimer. Push it down to that type. |
+ void didChangeAlignmentInterval(); |
+ |
+ // FIXME: This is only used by DOMTimer. Push it down to that type. |
void augmentRepeatInterval(double delta) { |
- setNextFireTime(m_nextFireTime + delta); |
+ setNextFireTime(nextFireTime() + delta); |
m_repeatInterval += delta; |
} |
- void didChangeAlignmentInterval(); |
- |
- static void fireTimersInNestedEventLoop(); |
- |
-private: |
+ // Used by ThreadTimers |
virtual void fired() = 0; |
+private: |
virtual double alignedFireTime(double fireTime) const { return fireTime; } |
- void checkConsistency() const; |
- void checkHeapIndex() const; |
- |
- void setNextFireTime(double); |
- |
- bool inHeap() const { return m_heapIndex != -1; } |
- |
- bool hasValidHeapPosition() const; |
- void updateHeapIfNeeded(double oldTime); |
- |
- void heapDecreaseKey(); |
- void heapDelete(); |
- void heapDeleteMin(); |
- void heapIncreaseKey(); |
- void heapInsert(); |
- void heapPop(); |
- void heapPopMin(); |
- |
- Vector<TimerBase*>& timerHeap() const { ASSERT(m_cachedThreadGlobalTimerHeap); return *m_cachedThreadGlobalTimerHeap; } |
- |
- double m_nextFireTime; // 0 if inactive |
double m_unalignedNextFireTime; // m_nextFireTime not considering alignment interval |
double m_repeatInterval; // 0 if not repeating |
- int m_heapIndex; // -1 if not in heap |
- unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time timers |
- Vector<TimerBase*>* m_cachedThreadGlobalTimerHeap; |
+ TimerHeapEntry m_heapEntry; |
WebTraceLocation m_location; |
#if ENABLE(ASSERT) |
ThreadIdentifier m_thread; |
#endif |
- |
- friend class ThreadTimers; |
- friend class TimerHeapLessThanFunction; |
- friend class TimerHeapReference; |
}; |
template<typename T, bool = IsGarbageCollectedType<T>::value> |
@@ -158,7 +147,7 @@ private: |
inline bool TimerBase::isActive() const |
{ |
ASSERT(m_thread == currentThread()); |
- return m_nextFireTime; |
+ return nextFireTime(); |
} |
} |