Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [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 | |||||
danakj | 0a44860 | 2015-03-10 00:31:16 | [diff] [blame] | 5 | #ifndef BASE_TIME_DEFAULT_TICK_CLOCK_H_ |
6 | #define BASE_TIME_DEFAULT_TICK_CLOCK_H_ | ||||
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [diff] [blame] | 7 | |
8 | #include "base/base_export.h" | ||||
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [diff] [blame] | 9 | #include "base/time/tick_clock.h" |
10 | |||||
11 | namespace base { | ||||
12 | |||||
Gabriel Charette | 996000b | 2019-08-14 23:41:19 | [diff] [blame] | 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 | ||||
David Munro | b51db0e | 2020-11-23 01:51:08 | [diff] [blame] | 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. | ||||
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [diff] [blame] | 19 | class BASE_EXPORT DefaultTickClock : public TickClock { |
20 | public: | ||||
dcheng | 5648818 | 2014-10-21 10:54:51 | [diff] [blame] | 21 | ~DefaultTickClock() override; |
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [diff] [blame] | 22 | |
23 | // Simply returns TimeTicks::Now(). | ||||
Greg Thompson | 821f0e338 | 2018-03-27 03:15:03 | [diff] [blame] | 24 | TimeTicks NowTicks() const override; |
tzik | aaa48e6 | 2017-11-28 07:43:43 | [diff] [blame] | 25 | |
26 | // Returns a shared instance of DefaultTickClock. This is thread-safe. | ||||
Greg Thompson | aa48ce8d | 2018-04-03 06:11:43 | [diff] [blame] | 27 | static const DefaultTickClock* GetInstance(); |
[email protected] | 0cb3d72e | 2013-02-21 21:50:34 | [diff] [blame] | 28 | }; |
29 | |||||
30 | } // namespace base | ||||
31 | |||||
danakj | 0a44860 | 2015-03-10 00:31:16 | [diff] [blame] | 32 | #endif // BASE_TIME_DEFAULT_TICK_CLOCK_H_ |