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_CLOCK_H_ 6*635a8641SAndroid Build Coastguard Worker #define BASE_TIME_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 Clock is an interface for objects that vend Times. 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 // time. 16*635a8641SAndroid Build Coastguard Worker // 17*635a8641SAndroid Build Coastguard Worker // See DefaultClock (base/time/default_clock.h) for the default 18*635a8641SAndroid Build Coastguard Worker // implementation that simply uses Time::Now(). 19*635a8641SAndroid Build Coastguard Worker // 20*635a8641SAndroid Build Coastguard Worker // (An implementation that uses Time::SystemTime() should be added as 21*635a8641SAndroid Build Coastguard Worker // needed.) 22*635a8641SAndroid Build Coastguard Worker // 23*635a8641SAndroid Build Coastguard Worker // See SimpleTestClock (base/test/simple_test_clock.h) for a simple 24*635a8641SAndroid Build Coastguard Worker // test implementation. 25*635a8641SAndroid Build Coastguard Worker // 26*635a8641SAndroid Build Coastguard Worker // See TickClock (base/time/tick_clock.h) for the equivalent interface for 27*635a8641SAndroid Build Coastguard Worker // TimeTicks. 28*635a8641SAndroid Build Coastguard Worker class BASE_EXPORT Clock { 29*635a8641SAndroid Build Coastguard Worker public: 30*635a8641SAndroid Build Coastguard Worker virtual ~Clock(); 31*635a8641SAndroid Build Coastguard Worker 32*635a8641SAndroid Build Coastguard Worker // Now() must be safe to call from any thread. The caller cannot 33*635a8641SAndroid Build Coastguard Worker // make any ordering assumptions about the returned Time. For 34*635a8641SAndroid Build Coastguard Worker // example, the system clock may change to an earlier time. 35*635a8641SAndroid Build Coastguard Worker virtual Time Now() 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_CLOCK_H_ 41