summaryrefslogtreecommitdiffstats
path: root/components/component_updater/timer.h
blob: 8b728996a96cf62f5c26bd9ee38ef0377b3890b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_COMPONENT_UPDATER_TIMER_H_
#define COMPONENTS_COMPONENT_UPDATER_TIMER_H_

#include "base/callback.h"
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"

namespace component_updater {

class Timer {
 public:
  Timer();
  ~Timer();

  void Start(base::TimeDelta initial_delay,
             base::TimeDelta delay,
             const base::Closure& user_task);

  void Stop();

 private:
  void OnDelay();

  base::ThreadChecker thread_checker_;

  base::Timer timer_;

  base::TimeDelta delay_;
  base::Closure user_task_;

  DISALLOW_COPY_AND_ASSIGN(Timer);
};

}  // namespace component_updater

#endif  // COMPONENTS_COMPONENT_UPDATER_TIMER_H_