#define Timer_h
#include "platform/PlatformExport.h"
+#include "platform/TraceLocation.h"
#include "wtf/Noncopyable.h"
#include "wtf/Threading.h"
#include "wtf/Vector.h"
TimerBase();
virtual ~TimerBase();
- void start(double nextFireInterval, double repeatInterval);
+ void start(double nextFireInterval, double repeatInterval, const TraceLocation&);
- void startRepeating(double repeatInterval) { start(repeatInterval, repeatInterval); }
- void startOneShot(double interval) { start(interval, 0); }
+ void startRepeating(double repeatInterval, const TraceLocation& caller)
+ {
+ start(repeatInterval, repeatInterval, caller);
+ }
+ void startOneShot(double interval, const TraceLocation& caller)
+ {
+ start(interval, 0, caller);
+ }
void stop();
bool isActive() const;
+ const TraceLocation& location() const { return m_location; }
double nextFireInterval() const;
double nextUnalignedFireInterval() const;
int m_heapIndex; // -1 if not in heap
unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time timers
Vector<TimerBase*>* m_cachedThreadGlobalTimerHeap;
+ TraceLocation m_location;
#ifndef NDEBUG
ThreadIdentifier m_thread;
};
template <typename TimerFiredClass>
-class Timer : public TimerBase {
+class Timer FINAL : public TimerBase {
public:
typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*);
: m_object(o), m_function(f) { }
private:
- virtual void fired() { (m_object->*m_function)(this); }
+ virtual void fired() OVERRIDE { (m_object->*m_function)(this); }
+ // FIXME: oilpan: TimerBase should be moved to the heap and m_object should be traced.
+ // This raw pointer is safe as long as Timer<X> is held by the X itself (That's the case
+ // in the current code base).
TimerFiredClass* m_object;
TimerFiredFunction m_function;
};
}
template <typename TimerFiredClass>
-class DeferrableOneShotTimer : private TimerBase {
+class DeferrableOneShotTimer FINAL : private TimerBase {
public:
typedef void (TimerFiredClass::*TimerFiredFunction)(DeferrableOneShotTimer*);
{
}
- void restart()
+ void restart(const TraceLocation& caller)
{
// Setting this boolean is much more efficient than calling startOneShot
// again, which might result in rescheduling the system timer which
m_shouldRestartWhenTimerFires = true;
return;
}
- startOneShot(m_delay);
+ startOneShot(m_delay, caller);
}
using TimerBase::stop;
using TimerBase::isActive;
private:
- virtual void fired()
+ virtual void fired() OVERRIDE
{
if (m_shouldRestartWhenTimerFires) {
m_shouldRestartWhenTimerFires = false;
- startOneShot(m_delay);
+ // FIXME: This should not be FROM_HERE.
+ startOneShot(m_delay, FROM_HERE);
return;
}
(m_object->*m_function)(this);
}
+ // FIXME: oilpan: TimerBase should be moved to the heap and m_object should be traced.
+ // This raw pointer is safe as long as Timer<X> is held by the X itself (That's the case
+ // in the current code base).
TimerFiredClass* m_object;
TimerFiredFunction m_function;