blob: d9e6124ca88ea07e3a91cd873ecf0f114b5c48bf [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
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_CLOCK_INTERFACE_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_CLOCK_INTERFACE_H__
7
8#include <string>
9
10#include <base/time.h>
11
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
42#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CLOCK_INTERFACE_H__