OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ | 5 #ifndef CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ |
6 #define CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ | 6 #define CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/values.h" |
9 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
10 #include "cc/scheduler/time_source.h" | 13 #include "cc/scheduler/time_source.h" |
11 | 14 |
12 namespace base { class SingleThreadTaskRunner; } | 15 namespace base { class SingleThreadTaskRunner; } |
13 | 16 |
14 namespace cc { | 17 namespace cc { |
15 | 18 |
16 // This timer implements a time source that achieves the specified interval | 19 // This timer implements a time source that achieves the specified interval |
17 // in face of millisecond-precision delayed callbacks and random queueing | 20 // in face of millisecond-precision delayed callbacks and random queueing |
18 // delays. DelayBasedTimeSource uses base::TimeTicks::Now as its timebase. | 21 // delays. DelayBasedTimeSource uses base::TimeTicks::Now as its timebase. |
19 class CC_EXPORT DelayBasedTimeSource : public TimeSource { | 22 class CC_EXPORT DelayBasedTimeSource : public TimeSource { |
20 public: | 23 public: |
21 static scoped_refptr<DelayBasedTimeSource> Create( | 24 static scoped_refptr<DelayBasedTimeSource> Create( |
22 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); | 25 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); |
23 | 26 |
24 virtual void SetClient(TimeSourceClient* client) OVERRIDE; | 27 virtual void SetClient(TimeSourceClient* client) OVERRIDE; |
25 | 28 |
26 // TimeSource implementation | 29 // TimeSource implementation |
27 virtual void SetTimebaseAndInterval(base::TimeTicks timebase, | 30 virtual void SetTimebaseAndInterval(base::TimeTicks timebase, |
28 base::TimeDelta interval) OVERRIDE; | 31 base::TimeDelta interval) OVERRIDE; |
29 | 32 |
30 virtual base::TimeTicks SetActive(bool active) OVERRIDE; | 33 virtual base::TimeTicks SetActive(bool active) OVERRIDE; |
31 virtual bool Active() const OVERRIDE; | 34 virtual bool Active() const OVERRIDE; |
32 | 35 |
33 // Get the last and next tick times. NextTickTime() returns null when | 36 // Get the last and next tick times. NextTickTime() returns null when |
34 // inactive. | 37 // inactive. |
35 virtual base::TimeTicks LastTickTime() OVERRIDE; | 38 virtual base::TimeTicks LastTickTime() const OVERRIDE; |
36 virtual base::TimeTicks NextTickTime() OVERRIDE; | 39 virtual base::TimeTicks NextTickTime() const OVERRIDE; |
37 | 40 |
38 // Virtual for testing. | 41 // Virtual for testing. |
39 virtual base::TimeTicks Now() const; | 42 virtual base::TimeTicks Now() const; |
40 | 43 |
| 44 virtual scoped_ptr<base::Value> AsValue() const; |
| 45 |
41 protected: | 46 protected: |
42 DelayBasedTimeSource(base::TimeDelta interval, | 47 DelayBasedTimeSource(base::TimeDelta interval, |
43 base::SingleThreadTaskRunner* task_runner); | 48 base::SingleThreadTaskRunner* task_runner); |
44 virtual ~DelayBasedTimeSource(); | 49 virtual ~DelayBasedTimeSource(); |
45 | 50 |
| 51 virtual std::string TypeString() const; |
| 52 |
46 base::TimeTicks NextTickTarget(base::TimeTicks now); | 53 base::TimeTicks NextTickTarget(base::TimeTicks now); |
47 void PostNextTickTask(base::TimeTicks now); | 54 void PostNextTickTask(base::TimeTicks now); |
48 void OnTimerFired(); | 55 void OnTimerFired(); |
49 | 56 |
50 struct Parameters { | 57 struct Parameters { |
51 Parameters(base::TimeDelta interval, base::TimeTicks tick_target) | 58 Parameters(base::TimeDelta interval, base::TimeTicks tick_target) |
52 : interval(interval), tick_target(tick_target) {} | 59 : interval(interval), tick_target(tick_target) {} |
53 base::TimeDelta interval; | 60 base::TimeDelta interval; |
54 base::TimeTicks tick_target; | 61 base::TimeTicks tick_target; |
55 }; | 62 }; |
(...skipping 23 matching lines...) Expand all Loading... |
79 static scoped_refptr<DelayBasedTimeSourceHighRes> Create( | 86 static scoped_refptr<DelayBasedTimeSourceHighRes> Create( |
80 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); | 87 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); |
81 | 88 |
82 virtual base::TimeTicks Now() const OVERRIDE; | 89 virtual base::TimeTicks Now() const OVERRIDE; |
83 | 90 |
84 protected: | 91 protected: |
85 DelayBasedTimeSourceHighRes(base::TimeDelta interval, | 92 DelayBasedTimeSourceHighRes(base::TimeDelta interval, |
86 base::SingleThreadTaskRunner* task_runner); | 93 base::SingleThreadTaskRunner* task_runner); |
87 virtual ~DelayBasedTimeSourceHighRes(); | 94 virtual ~DelayBasedTimeSourceHighRes(); |
88 | 95 |
| 96 virtual std::string TypeString() const OVERRIDE; |
| 97 |
89 private: | 98 private: |
90 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSourceHighRes); | 99 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSourceHighRes); |
91 }; | 100 }; |
92 | 101 |
93 } // namespace cc | 102 } // namespace cc |
94 | 103 |
95 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ | 104 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ |
OLD | NEW |