blob: ef37e50cb126fb1e9342575f8e3d48344dacf6f5 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2012 The Chromium Authors
[email protected]0cb3d72e2013-02-21 21:50:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
danakj0a448602015-03-10 00:31:165#ifndef BASE_TIME_DEFAULT_TICK_CLOCK_H_
6#define BASE_TIME_DEFAULT_TICK_CLOCK_H_
[email protected]0cb3d72e2013-02-21 21:50:347
8#include "base/base_export.h"
[email protected]0cb3d72e2013-02-21 21:50:349#include "base/time/tick_clock.h"
10
11namespace base {
12
Gabriel Charette996000b2019-08-14 23:41:1913// 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 Munrob51db0e2020-11-23 01:51:0816// 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]0cb3d72e2013-02-21 21:50:3419class BASE_EXPORT DefaultTickClock : public TickClock {
20 public:
dcheng56488182014-10-21 10:54:5121 ~DefaultTickClock() override;
[email protected]0cb3d72e2013-02-21 21:50:3422
23 // Simply returns TimeTicks::Now().
Greg Thompson821f0e3382018-03-27 03:15:0324 TimeTicks NowTicks() const override;
tzikaaa48e62017-11-28 07:43:4325
26 // Returns a shared instance of DefaultTickClock. This is thread-safe.
Greg Thompsonaa48ce8d2018-04-03 06:11:4327 static const DefaultTickClock* GetInstance();
[email protected]0cb3d72e2013-02-21 21:50:3428};
29
30} // namespace base
31
danakj0a448602015-03-10 00:31:1632#endif // BASE_TIME_DEFAULT_TICK_CLOCK_H_