1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker #ifndef BASE_TIME_TICK_CLOCK_H_ 6*635a8641SAndroid Build Coastguard Worker #define BASE_TIME_TICK_CLOCK_H_ 7*635a8641SAndroid Build Coastguard Worker 8*635a8641SAndroid Build Coastguard Worker #include "base/base_export.h" 9*635a8641SAndroid Build Coastguard Worker #include "base/time/time.h" 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard Worker namespace base { 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker // A TickClock is an interface for objects that vend TimeTicks. It is 14*635a8641SAndroid Build Coastguard Worker // intended to be able to test the behavior of classes with respect to 15*635a8641SAndroid Build Coastguard Worker // non-decreasing time. 16*635a8641SAndroid Build Coastguard Worker // 17*635a8641SAndroid Build Coastguard Worker // See DefaultTickClock (base/time/default_tick_clock.h) for the default 18*635a8641SAndroid Build Coastguard Worker // implementation that simply uses TimeTicks::Now(). 19*635a8641SAndroid Build Coastguard Worker // 20*635a8641SAndroid Build Coastguard Worker // (Other implementations that use TimeTicks::NowFromSystemTime() should 21*635a8641SAndroid Build Coastguard Worker // be added as needed.) 22*635a8641SAndroid Build Coastguard Worker // 23*635a8641SAndroid Build Coastguard Worker // See SimpleTestTickClock (base/test/simple_test_tick_clock.h) for a 24*635a8641SAndroid Build Coastguard Worker // simple test implementation. 25*635a8641SAndroid Build Coastguard Worker // 26*635a8641SAndroid Build Coastguard Worker // See Clock (base/time/clock.h) for the equivalent interface for Times. 27*635a8641SAndroid Build Coastguard Worker class BASE_EXPORT TickClock { 28*635a8641SAndroid Build Coastguard Worker public: 29*635a8641SAndroid Build Coastguard Worker virtual ~TickClock(); 30*635a8641SAndroid Build Coastguard Worker 31*635a8641SAndroid Build Coastguard Worker // NowTicks() must be safe to call from any thread. The caller may 32*635a8641SAndroid Build Coastguard Worker // assume that NowTicks() is monotonic (but not strictly monotonic). 33*635a8641SAndroid Build Coastguard Worker // In other words, the returned TimeTicks will never decrease with 34*635a8641SAndroid Build Coastguard Worker // time, although they might "stand still". 35*635a8641SAndroid Build Coastguard Worker virtual TimeTicks NowTicks() const = 0; 36*635a8641SAndroid Build Coastguard Worker }; 37*635a8641SAndroid Build Coastguard Worker 38*635a8641SAndroid Build Coastguard Worker } // namespace base 39*635a8641SAndroid Build Coastguard Worker 40*635a8641SAndroid Build Coastguard Worker #endif // BASE_TIME_TICK_CLOCK_H_ 41