default_tick_clock.h 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_TIME_DEFAULT_TICK_CLOCK_H_
  5. #define BASE_TIME_DEFAULT_TICK_CLOCK_H_
  6. #include "base/base_export.h"
  7. #include "base/time/tick_clock.h"
  8. namespace base {
  9. // DefaultTickClock is a TickClock implementation that uses TimeTicks::Now().
  10. // This is typically used by components that expose a SetTickClockForTesting().
  11. // Note: Overriding Time/TimeTicks altogether via
  12. // TaskEnvironment::TimeSource::MOCK_TIME is now the preferred of
  13. // overriding time in unit tests. As such, there shouldn't be many new use cases
  14. // for TickClock/DefaultTickClock anymore.
  15. class BASE_EXPORT DefaultTickClock : public TickClock {
  16. public:
  17. ~DefaultTickClock() override;
  18. // Simply returns TimeTicks::Now().
  19. TimeTicks NowTicks() const override;
  20. // Returns a shared instance of DefaultTickClock. This is thread-safe.
  21. static const DefaultTickClock* GetInstance();
  22. };
  23. } // namespace base
  24. #endif // BASE_TIME_DEFAULT_TICK_CLOCK_H_