Chromium Code Reviews| Index: cc/scheduler/delay_based_time_source.h |
| diff --git a/cc/scheduler/delay_based_time_source.h b/cc/scheduler/delay_based_time_source.h |
| index 99df6dbafe6d42f49b0ffe4772f7125a5ccd91fb..41fb89ceb33a01a1a2146f800f10da55a00616f7 100644 |
| --- a/cc/scheduler/delay_based_time_source.h |
| +++ b/cc/scheduler/delay_based_time_source.h |
| @@ -7,6 +7,7 @@ |
| #include <string> |
| +#include "base/cancelable_callback.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/values.h" |
| #include "cc/base/cc_export.h" |
| @@ -19,13 +20,12 @@ class SingleThreadTaskRunner; |
| } |
| namespace cc { |
| - |
| -class CC_EXPORT TimeSourceClient { |
| +class CC_EXPORT DelayBasedTimeSourceClient { |
| public: |
| virtual void OnTimerTick() = 0; |
| protected: |
| - virtual ~TimeSourceClient() {} |
| + virtual ~DelayBasedTimeSourceClient() {} |
| }; |
| // This timer implements a time source that achieves the specified interval |
| @@ -41,23 +41,21 @@ class CC_EXPORT DelayBasedTimeSource { |
| virtual ~DelayBasedTimeSource(); |
| - virtual void SetClient(TimeSourceClient* client); |
| + void SetClient(DelayBasedTimeSourceClient* client); |
| + |
| + void SetTimebaseAndInterval(base::TimeTicks timebase, |
| + base::TimeDelta interval); |
| - // TimeSource implementation |
| - virtual void SetTimebaseAndInterval(base::TimeTicks timebase, |
| - base::TimeDelta interval); |
| - base::TimeDelta Interval() const { return next_parameters_.interval; } |
| + base::TimeDelta Interval() const; |
| - virtual base::TimeTicks SetActive(bool active); |
| - virtual bool Active() const; |
| + // Returns the time for the the last missed tick. |
|
mithro-old
2015/07/06 11:29:12
nit: the the
|
| + base::TimeTicks SetActive(bool active); |
| + bool Active() const; |
| // Get the last and next tick times. NextTickTime() returns null when |
| // inactive. |
| - virtual base::TimeTicks LastTickTime() const; |
| - virtual base::TimeTicks NextTickTime() const; |
| - |
| - // Virtual for testing. |
| - virtual base::TimeTicks Now() const; |
| + base::TimeTicks LastTickTime() const; |
| + base::TimeTicks NextTickTime() const; |
| virtual void AsValueInto(base::trace_event::TracedValue* dict) const; |
| @@ -65,35 +63,34 @@ class CC_EXPORT DelayBasedTimeSource { |
| DelayBasedTimeSource(base::TimeDelta interval, |
| base::SingleThreadTaskRunner* task_runner); |
| + // Virtual for testing. |
| + virtual base::TimeTicks Now() const; |
| virtual std::string TypeString() const; |
| - base::TimeTicks NextTickTarget(base::TimeTicks now); |
| + base::TimeTicks NextTickTarget(base::TimeTicks now) const; |
| + |
| void PostNextTickTask(base::TimeTicks now); |
| - void OnTimerFired(); |
| + void ResetTickTask(base::TimeTicks now); |
| - struct Parameters { |
| - Parameters(base::TimeDelta interval, base::TimeTicks tick_target) |
| - : interval(interval), tick_target(tick_target) {} |
| - base::TimeDelta interval; |
| - base::TimeTicks tick_target; |
| - }; |
| + void OnTimerTick(); |
| - TimeSourceClient* client_; |
| - base::TimeTicks last_tick_time_; |
| - |
| - // current_parameters_ should only be written by PostNextTickTask. |
| - // next_parameters_ will take effect on the next call to PostNextTickTask. |
| - // Maintaining a pending set of parameters allows NextTickTime() to always |
| - // reflect the actual time we expect OnTimerFired to be called. |
| - Parameters current_parameters_; |
| - Parameters next_parameters_; |
| + DelayBasedTimeSourceClient* client_; |
| bool active_; |
|
mithro-old
2015/07/06 11:29:12
nit: Should some of these actually be private?
|
| + base::TimeTicks timebase_; |
| + base::TimeDelta interval_; |
| + |
| + base::TimeTicks last_tick_time_; |
| + base::TimeTicks next_tick_time_; |
| + |
| + base::CancelableClosure tick_closure_; |
| + |
| base::SingleThreadTaskRunner* task_runner_; |
| - base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_; |
| private: |
| + base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSource); |
| }; |