1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/component_updater/timer.h"
7 #include "base/functional/bind.h"
8 #include "base/location.h"
10 namespace component_updater {
12 Timer::Timer() = default;
18 void Timer::Start(base::TimeDelta initial_delay,
19 base::TimeDelta delay,
20 const base::RepeatingClosure& user_task) {
21 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
24 user_task_ = user_task;
26 timer_.Start(FROM_HERE, initial_delay,
27 base::BindOnce(&Timer::OnDelay, base::Unretained(this)));
31 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
35 void Timer::OnDelay() {
36 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
40 timer_.Start(FROM_HERE, delay_,
41 base::BindOnce(&Timer::OnDelay, base::Unretained(this)));
44 } // namespace component_updater