blob: 8ff122c4c96605b9022b56a3703e9752d8932cea [file] [log] [blame]
David Zeuthenf413fe52013-04-22 14:04:39 -07001// Copyright (c) 2013 The Chromium OS 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
Gilad Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_CLOCK_INTERFACE_H_
6#define UPDATE_ENGINE_CLOCK_INTERFACE_H_
David Zeuthenf413fe52013-04-22 14:04:39 -07007
8#include <string>
9
Alex Vakulenko75039d72014-03-25 12:36:28 -070010#include <base/time/time.h>
David Zeuthenf413fe52013-04-22 14:04:39 -070011
12namespace chromeos_update_engine {
13
14// The clock interface allows access to various system clocks. The
15// sole reason for providing this as an interface is unit testing.
16// Additionally, the sole reason for the methods not being static
17// is also unit testing.
18class ClockInterface {
19 public:
Alex Deymo610277e2014-11-11 21:18:11 -080020 virtual ~ClockInterface() = default;
21
David Zeuthenf413fe52013-04-22 14:04:39 -070022 // Gets the current time e.g. similar to base::Time::Now().
23 virtual base::Time GetWallclockTime() = 0;
24
25 // Returns monotonic time since some unspecified starting point. It
26 // is not increased when the system is sleeping nor is it affected
27 // by NTP or the user changing the time.
28 //
29 // (This is a simple wrapper around clock_gettime(2) / CLOCK_MONOTONIC_RAW.)
30 virtual base::Time GetMonotonicTime() = 0;
31
David Zeuthen3c55abd2013-10-14 12:48:03 -070032 // Returns monotonic time since some unspecified starting point. It
33 // is increased when the system is sleeping but it's not affected
34 // by NTP or the user changing the time.
35 //
36 // (This is a simple wrapper around clock_gettime(2) / CLOCK_BOOTTIME.)
37 virtual base::Time GetBootTime() = 0;
David Zeuthenf413fe52013-04-22 14:04:39 -070038};
39
40} // namespace chromeos_update_engine
41
Gilad Arnoldcf175a02014-07-10 16:48:47 -070042#endif // UPDATE_ENGINE_CLOCK_INTERFACE_H_