1 // Copyright 2012 The Chromium Authors 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 BASE_TIME_DEFAULT_TICK_CLOCK_H_ 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 way of overriding 17 // time in unit tests. As such, there shouldn't be many new use cases for 18 // 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