[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / component_updater / timer.cc
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.
4
5 #include "components/component_updater/timer.h"
6
7 #include "base/functional/bind.h"
8 #include "base/location.h"
9
10 namespace component_updater {
11
12 Timer::Timer() = default;
13
14 Timer::~Timer() {
15   Stop();
16 }
17
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_);
22
23   delay_ = delay;
24   user_task_ = user_task;
25
26   timer_.Start(FROM_HERE, initial_delay,
27                base::BindOnce(&Timer::OnDelay, base::Unretained(this)));
28 }
29
30 void Timer::Stop() {
31   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
32   timer_.Stop();
33 }
34
35 void Timer::OnDelay() {
36   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
37
38   user_task_.Run();
39
40   timer_.Start(FROM_HERE, delay_,
41                base::BindOnce(&Timer::OnDelay, base::Unretained(this)));
42 }
43
44 }  // namespace component_updater