timer_update_scheduler.cc 977 B

1234567891011121314151617181920212223242526272829
  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. #include "components/component_updater/timer_update_scheduler.h"
  5. #include "base/bind.h"
  6. #include "base/callback_helpers.h"
  7. namespace component_updater {
  8. TimerUpdateScheduler::TimerUpdateScheduler() = default;
  9. TimerUpdateScheduler::~TimerUpdateScheduler() = default;
  10. void TimerUpdateScheduler::Schedule(const base::TimeDelta& initial_delay,
  11. const base::TimeDelta& delay,
  12. const UserTask& user_task,
  13. const OnStopTaskCallback& on_stop) {
  14. timer_.Start(
  15. initial_delay, delay,
  16. base::BindRepeating(
  17. [](const UserTask& user_task) { user_task.Run(base::DoNothing()); },
  18. user_task));
  19. }
  20. void TimerUpdateScheduler::Stop() {
  21. timer_.Stop();
  22. }
  23. } // namespace component_updater