tick_clock.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_TICK_CLOCK_H_
  5. #define BASE_TIME_TICK_CLOCK_H_
  6. #include "base/base_export.h"
  7. #include "base/time/time.h"
  8. namespace base {
  9. // A TickClock is an interface for objects that vend TimeTicks. It is
  10. // intended to be able to test the behavior of classes with respect to
  11. // non-decreasing time.
  12. //
  13. // See DefaultTickClock (base/time/default_tick_clock.h) for the default
  14. // implementation that simply uses TimeTicks::Now().
  15. //
  16. // (Other implementations that use TimeTicks::NowFromSystemTime() should
  17. // be added as needed.)
  18. //
  19. // See SimpleTestTickClock (base/test/simple_test_tick_clock.h) for a
  20. // simple test implementation.
  21. //
  22. // See Clock (base/time/clock.h) for the equivalent interface for Times.
  23. class BASE_EXPORT TickClock {
  24. public:
  25. virtual ~TickClock();
  26. // NowTicks() must be safe to call from any thread. The caller may
  27. // assume that NowTicks() is monotonic (but not strictly monotonic).
  28. // In other words, the returned TimeTicks will never decrease with
  29. // time, although they might "stand still".
  30. virtual TimeTicks NowTicks() const = 0;
  31. };
  32. } // namespace base
  33. #endif // BASE_TIME_TICK_CLOCK_H_