blob: bafb7fcbb2db8df3a9bdb0e55e8cdcb382b2ffd4 [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:
20 // Gets the current time e.g. similar to base::Time::Now().
21 virtual base::Time GetWallclockTime() = 0;
22
23 // Returns monotonic time since some unspecified starting point. It
24 // is not increased when the system is sleeping nor is it affected
25 // by NTP or the user changing the time.
26 //
27 // (This is a simple wrapper around clock_gettime(2) / CLOCK_MONOTONIC_RAW.)
28 virtual base::Time GetMonotonicTime() = 0;
29
David Zeuthen3c55abd2013-10-14 12:48:03 -070030 // Returns monotonic time since some unspecified starting point. It
31 // is increased when the system is sleeping but it's not affected
32 // by NTP or the user changing the time.
33 //
34 // (This is a simple wrapper around clock_gettime(2) / CLOCK_BOOTTIME.)
35 virtual base::Time GetBootTime() = 0;
36
David Zeuthenf413fe52013-04-22 14:04:39 -070037 virtual ~ClockInterface() {}
38};
39
40} // namespace chromeos_update_engine
41
Gilad Arnoldcf175a02014-07-10 16:48:47 -070042#endif // UPDATE_ENGINE_CLOCK_INTERFACE_H_