blob: 17d748f854c0368784b2cf3d07773c0b36772eaa [file] [log] [blame]
Paul Stewarte6927402012-01-23 16:11:30 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Paul Stewartc2350ee2011-10-19 12:28:40 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_TIME_H_
6#define SHILL_TIME_H_
7
8#include <sys/time.h>
9
10#include <base/lazy_instance.h>
11
12namespace shill {
13
14// A "sys/time.h" abstraction allowing mocking in tests.
15class Time {
16 public:
17 virtual ~Time();
18
19 static Time *GetInstance();
20
Paul Stewarte6927402012-01-23 16:11:30 -080021 // clock_gettime(CLOCK_MONOTONIC ...
22 virtual int GetTimeMonotonic(struct timeval *tv);
23
Paul Stewartc2350ee2011-10-19 12:28:40 -070024 // gettimeofday
25 virtual int GetTimeOfDay(struct timeval *tv, struct timezone *tz);
26
27 protected:
28 Time();
29
30 private:
31 friend struct base::DefaultLazyInstanceTraits<Time>;
32
33 DISALLOW_COPY_AND_ASSIGN(Time);
34};
35
36} // namespace shill
37
38#endif // SHILL_TIME_H_