| 6 | #define BASE_TIME_DEFAULT_TICK_CLOCK_H_ |
| 7 |
| 8 | #include "base/base_export.h" |
| 9 | #include "base/time/tick_clock.h" |
| 10 |
| 11 | namespace base { |
| 12 |
| 13 | // DefaultTickClock is a TickClock implementation that uses TimeTicks::Now(). |
| 14 | // This is typically used by components that expose a SetTickClockForTesting(). |
| 15 | // Note: Overriding Time/TimeTicks altogether via |
| 16 | // TaskEnvironment::TimeSource::MOCK_TIME is now the preferred of |
| 17 | // overriding time in unit tests. As such, there shouldn't be many new use cases |
| 18 | // for TickClock/DefaultTickClock anymore. |
| 19 | class BASE_EXPORT DefaultTickClock : public TickClock { |
| 20 | public: |
| 21 | ~DefaultTickClock() override; |
| 22 |
| 23 | // Simply returns TimeTicks::Now(). |
| 24 | TimeTicks NowTicks() const override; |
| 25 |
| 26 | // Returns a shared instance of DefaultTickClock. This is thread-safe. |
| 27 | static const DefaultTickClock* GetInstance(); |
| 28 | }; |
| 29 |
| 30 | } // namespace base |
| 31 |
| 32 | #endif // BASE_TIME_DEFAULT_TICK_CLOCK_H_ |
| 33 |