1 // Copyright 2015 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.
5 #include "components/component_updater/timer.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
11 namespace component_updater
{
13 Timer::Timer() : timer_(false, false) {
17 DCHECK(thread_checker_
.CalledOnValidThread());
21 void Timer::Start(base::TimeDelta initial_delay
,
22 base::TimeDelta delay
,
23 const base::Closure
& user_task
) {
24 DCHECK(thread_checker_
.CalledOnValidThread());
27 user_task_
= user_task
;
29 timer_
.Start(FROM_HERE
, initial_delay
,
30 base::Bind(&Timer::OnDelay
, base::Unretained(this)));
34 DCHECK(thread_checker_
.CalledOnValidThread());
38 void Timer::OnDelay() {
39 DCHECK(thread_checker_
.CalledOnValidThread());
43 timer_
.Start(FROM_HERE
, delay_
,
44 base::Bind(&Timer::OnDelay
, base::Unretained(this)));
47 } // namespace component_updater