1 // Copyright 2011 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.
5 #ifndef CC_SCHEDULER_TIME_SOURCE_H_
6 #define CC_SCHEDULER_TIME_SOURCE_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "cc/base/cc_export.h"
14 class CC_EXPORT TimeSourceClient
{
16 virtual void OnTimerTick() = 0;
19 virtual ~TimeSourceClient() {}
22 // An generic interface for getting a reliably-ticking timesource of
25 // Be sure to call SetActive(false) before releasing your reference to the
26 // timer, or it will keep on ticking!
27 class CC_EXPORT TimeSource
: public base::RefCounted
<TimeSource
> {
29 virtual void SetClient(TimeSourceClient
* client
) = 0;
31 // If transitioning from not active to active, SetActive will return the
32 // timestamp of the most recenly missed tick that did not have OnTimerTick
34 virtual base::TimeTicks
SetActive(bool active
) = 0;
36 virtual bool Active() const = 0;
37 virtual void SetTimebaseAndInterval(base::TimeTicks timebase
,
38 base::TimeDelta interval
) = 0;
39 virtual base::TimeTicks
LastTickTime() = 0;
40 virtual base::TimeTicks
NextTickTime() = 0;
43 virtual ~TimeSource() {}
46 friend class base::RefCounted
<TimeSource
>;
51 #endif // CC_SCHEDULER_TIME_SOURCE_H_