Commit c9fe54cc authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Use TimeDelta in PausableTimer

Mostly s/double/TimeDelta/ and Method() to MethodDelta(). The
kNextFireIntervalInvalid constant is changed to TimeDelta::Min().

Bug: 763980
Change-Id: I878a4136edcfe815184e7021a19eefffbc02fd31
Reviewed-on: https://chromium-review.googlesource.com/1125919Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#572612}
parent 1d3890ca
......@@ -31,15 +31,14 @@
namespace blink {
namespace {
// The lowest value returned by TimerBase::nextUnalignedFireInterval is 0.0
const double kNextFireIntervalInvalid = -1.0;
// TimerBase::NextFireIntervalDelta returns a delta >= 0.
constexpr TimeDelta kNextFireIntervalInvalid = TimeDelta::Min();
} // namespace
PausableTimer::PausableTimer(ExecutionContext* context, TaskType task_type)
: TimerBase(context->GetTaskRunner(task_type)),
PausableObject(context),
next_fire_interval_(kNextFireIntervalInvalid),
repeat_interval_(0) {
next_fire_interval_(kNextFireIntervalInvalid) {
DCHECK(context);
}
......@@ -60,9 +59,9 @@ void PausableTimer::Pause() {
paused_ = true;
#endif
if (IsActive()) {
next_fire_interval_ = NextFireInterval();
DCHECK_GE(next_fire_interval_, 0.0);
repeat_interval_ = RepeatInterval();
next_fire_interval_ = NextFireIntervalDelta();
DCHECK_GE(next_fire_interval_, TimeDelta());
repeat_interval_ = RepeatIntervalDelta();
TimerBase::Stop();
}
}
......@@ -72,7 +71,7 @@ void PausableTimer::Unpause() {
DCHECK(paused_);
paused_ = false;
#endif
if (next_fire_interval_ >= 0.0) {
if (next_fire_interval_ >= TimeDelta()) {
// start() was called before, therefore location() is already set.
// m_nextFireInterval is only set in suspend() if the Timer was active.
Start(next_fire_interval_, repeat_interval_, GetLocation());
......
......@@ -48,8 +48,8 @@ class CORE_EXPORT PausableTimer : public TimerBase, public PausableObject {
private:
void Fired() override = 0;
double next_fire_interval_;
double repeat_interval_;
TimeDelta next_fire_interval_;
TimeDelta repeat_interval_;
#if DCHECK_IS_ON()
bool paused_ = false;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment