Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | c2350ee | 2011-10-19 12:28:40 -0700 | [diff] [blame] | 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 SHILL_TIME_H_ |
| 6 | #define SHILL_TIME_H_ |
| 7 | |
| 8 | #include <sys/time.h> |
| 9 | |
| 10 | #include <base/lazy_instance.h> |
| 11 | |
| 12 | namespace shill { |
| 13 | |
| 14 | // A "sys/time.h" abstraction allowing mocking in tests. |
| 15 | class Time { |
| 16 | public: |
| 17 | virtual ~Time(); |
| 18 | |
| 19 | static Time *GetInstance(); |
| 20 | |
Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 21 | // clock_gettime(CLOCK_MONOTONIC ... |
| 22 | virtual int GetTimeMonotonic(struct timeval *tv); |
| 23 | |
Paul Stewart | c2350ee | 2011-10-19 12:28:40 -0700 | [diff] [blame] | 24 | // 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_ |