blob: c2b1a046a5db576c6e61fc876a42eb4d90042c29 [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
30 virtual ~ClockInterface() {}
31};
32
33} // namespace chromeos_update_engine
34
35#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CLOCK_INTERFACE_H__