SuspendableTimer.h [plain text]
#pragma once
#include "ActiveDOMObject.h"
#include "Timer.h"
namespace WebCore {
class SuspendableTimer : private TimerBase, public ActiveDOMObject {
public:
explicit SuspendableTimer(ScriptExecutionContext&);
virtual ~SuspendableTimer();
virtual void didStop();
bool isActive() const { return TimerBase::isActive() || (m_suspended && m_savedIsActive); }
bool isSuspended() const { return m_suspended; }
void startRepeating(double repeatInterval);
void startOneShot(double interval);
double repeatInterval() const;
void augmentFireInterval(double delta);
void augmentRepeatInterval(double delta);
void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(msToSeconds(repeatInterval)); }
void startOneShot(std::chrono::milliseconds interval) { startOneShot(msToSeconds(interval)); }
std::chrono::milliseconds repeatIntervalMS() const { return secondsToMS(repeatInterval()); }
void augmentFireInterval(std::chrono::milliseconds delta) { augmentFireInterval(msToSeconds(delta)); }
void augmentRepeatInterval(std::chrono::milliseconds delta) { augmentRepeatInterval(msToSeconds(delta)); }
using TimerBase::didChangeAlignmentInterval;
using TimerBase::operator new;
using TimerBase::operator delete;
void cancel();
private:
void fired() override = 0;
bool hasPendingActivity() const final;
void stop() final;
bool canSuspendForDocumentSuspension() const final;
void suspend(ReasonForSuspension) final;
void resume() final;
bool m_suspended;
double m_savedNextFireInterval;
double m_savedRepeatInterval;
bool m_savedIsActive;
};
}