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 @@ ...@@ -31,15 +31,14 @@
namespace blink { namespace blink {
namespace { namespace {
// The lowest value returned by TimerBase::nextUnalignedFireInterval is 0.0 // TimerBase::NextFireIntervalDelta returns a delta >= 0.
const double kNextFireIntervalInvalid = -1.0; constexpr TimeDelta kNextFireIntervalInvalid = TimeDelta::Min();
} // namespace } // namespace
PausableTimer::PausableTimer(ExecutionContext* context, TaskType task_type) PausableTimer::PausableTimer(ExecutionContext* context, TaskType task_type)
: TimerBase(context->GetTaskRunner(task_type)), : TimerBase(context->GetTaskRunner(task_type)),
PausableObject(context), PausableObject(context),
next_fire_interval_(kNextFireIntervalInvalid), next_fire_interval_(kNextFireIntervalInvalid) {
repeat_interval_(0) {
DCHECK(context); DCHECK(context);
} }
...@@ -60,9 +59,9 @@ void PausableTimer::Pause() { ...@@ -60,9 +59,9 @@ void PausableTimer::Pause() {
paused_ = true; paused_ = true;
#endif #endif
if (IsActive()) { if (IsActive()) {
next_fire_interval_ = NextFireInterval(); next_fire_interval_ = NextFireIntervalDelta();
DCHECK_GE(next_fire_interval_, 0.0); DCHECK_GE(next_fire_interval_, TimeDelta());
repeat_interval_ = RepeatInterval(); repeat_interval_ = RepeatIntervalDelta();
TimerBase::Stop(); TimerBase::Stop();
} }
} }
...@@ -72,7 +71,7 @@ void PausableTimer::Unpause() { ...@@ -72,7 +71,7 @@ void PausableTimer::Unpause() {
DCHECK(paused_); DCHECK(paused_);
paused_ = false; paused_ = false;
#endif #endif
if (next_fire_interval_ >= 0.0) { if (next_fire_interval_ >= TimeDelta()) {
// start() was called before, therefore location() is already set. // start() was called before, therefore location() is already set.
// m_nextFireInterval is only set in suspend() if the Timer was active. // m_nextFireInterval is only set in suspend() if the Timer was active.
Start(next_fire_interval_, repeat_interval_, GetLocation()); Start(next_fire_interval_, repeat_interval_, GetLocation());
......
...@@ -48,8 +48,8 @@ class CORE_EXPORT PausableTimer : public TimerBase, public PausableObject { ...@@ -48,8 +48,8 @@ class CORE_EXPORT PausableTimer : public TimerBase, public PausableObject {
private: private:
void Fired() override = 0; void Fired() override = 0;
double next_fire_interval_; TimeDelta next_fire_interval_;
double repeat_interval_; TimeDelta repeat_interval_;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
bool paused_ = false; bool paused_ = false;
#endif #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