#ifndef DOMTimer_h
#define DOMTimer_h
#include "SuspendableTimer.h"
#include <memory>
#include <wtf/RefCounted.h>
namespace WebCore {
class DOMTimerFireState;
class Document;
class Element;
class HTMLPlugInElement;
class IntRect;
class ScheduledAction;
class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
WTF_MAKE_NONCOPYABLE(DOMTimer);
WTF_MAKE_FAST_ALLOCATED;
public:
virtual ~DOMTimer();
static double defaultMinimumInterval() { return 0.004; } static double defaultAlignmentInterval() { return 0; }
static double hiddenPageAlignmentInterval() { return 1.0; }
static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
static void removeById(ScriptExecutionContext&, int timeoutId);
void updateTimerIntervalIfNecessary();
static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
private:
DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
friend class Internals;
double intervalClampedToMinimum() const;
bool isDOMTimersThrottlingEnabled(Document&) const;
void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
virtual void fired() override;
virtual void didStop() override;
virtual double alignedFireTime(double) const override;
const char* activeDOMObjectName() const override;
enum TimerThrottleState {
Undetermined,
ShouldThrottle,
ShouldNotThrottle
};
int m_timeoutId;
int m_nestingLevel;
std::unique_ptr<ScheduledAction> m_action;
int m_originalInterval;
TimerThrottleState m_throttleState;
double m_currentTimerInterval;
bool m_shouldForwardUserGesture;
};
}
#endif // DOMTimer_h