timer_update_scheduler.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_COMPONENT_UPDATER_TIMER_UPDATE_SCHEDULER_H_
  5. #define COMPONENTS_COMPONENT_UPDATER_TIMER_UPDATE_SCHEDULER_H_
  6. #include "base/callback.h"
  7. #include "components/component_updater/timer.h"
  8. #include "components/component_updater/update_scheduler.h"
  9. namespace component_updater {
  10. // Scheduler that uses base::Timer to schedule updates.
  11. class TimerUpdateScheduler : public UpdateScheduler {
  12. public:
  13. TimerUpdateScheduler();
  14. TimerUpdateScheduler(const TimerUpdateScheduler&) = delete;
  15. TimerUpdateScheduler& operator=(const TimerUpdateScheduler&) = delete;
  16. ~TimerUpdateScheduler() override;
  17. // UpdateScheduler:
  18. void Schedule(const base::TimeDelta& initial_delay,
  19. const base::TimeDelta& delay,
  20. const UserTask& user_task,
  21. const OnStopTaskCallback& on_stop) override;
  22. void Stop() override;
  23. private:
  24. Timer timer_;
  25. base::RepeatingClosure user_task_;
  26. };
  27. } // namespace component_updater
  28. #endif // COMPONENTS_COMPONENT_UPDATER_TIMER_UPDATE_SCHEDULER_H_