// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_TIMER_WALL_CLOCK_TIMER_H_ #define BASE_TIMER_WALL_CLOCK_TIMER_H_ #include "base/base_export.h" #include "base/functional/bind.h" #include "base/functional/callback.h" #include "base/location.h" #include "base/memory/raw_ptr.h" #include "base/power_monitor/power_observer.h" #include "base/time/default_clock.h" #include "base/time/time.h" #include "base/timer/timer.h" namespace base { class Clock; class TickClock; // WallClockTimer is based on OneShotTimer and provides a simple timer API // which is mostly similar to OneShotTimer's API. The main difference is that // WallClockTimer is using Time (which is system-dependent) to schedule task. // WallClockTimer calls you back once scheduled time has come. // // Comparison with OneShotTimer: WallClockTimer runs |user_task_| after |delay_| // expires according to usual time, while OneShotTimer runs |user_task_| after // |delay_| expires according to TimeTicks which may freeze on some platforms // when power suspends (desktop falls asleep). On platforms where TimeTicks // don't freeze, the WallClockTimer has the same behavior as OneShotTimer. // // The API is not thread safe. All methods must be called from the same // sequence (not necessarily the construction sequence), except for the // destructor. // - The destructor may be called from any sequence when the timer is not // running and there is no scheduled task active. class BASE_EXPORT WallClockTimer : public PowerSuspendObserver { … }; } // namespace base #endif // BASE_TIMER_WALL_CLOCK_TIMER_H_