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 "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/scheduler/time_source.h" | 10 #include "cc/scheduler/time_source.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 protected: | 41 protected: |
42 DelayBasedTimeSource(base::TimeDelta interval, | 42 DelayBasedTimeSource(base::TimeDelta interval, |
43 base::SingleThreadTaskRunner* task_runner); | 43 base::SingleThreadTaskRunner* task_runner); |
44 virtual ~DelayBasedTimeSource(); | 44 virtual ~DelayBasedTimeSource(); |
45 | 45 |
46 base::TimeTicks NextTickTarget(base::TimeTicks now); | 46 base::TimeTicks NextTickTarget(base::TimeTicks now); |
47 void PostNextTickTask(base::TimeTicks now); | 47 void PostNextTickTask(base::TimeTicks now); |
48 void OnTimerFired(); | 48 void OnTimerFired(); |
49 | 49 |
| 50 enum State { |
| 51 STATE_INACTIVE, |
| 52 STATE_STARTING, |
| 53 STATE_ACTIVE, |
| 54 }; |
| 55 |
50 struct Parameters { | 56 struct Parameters { |
51 Parameters(base::TimeDelta interval, base::TimeTicks tick_target) | 57 Parameters(base::TimeDelta interval, base::TimeTicks tick_target) |
52 : interval(interval), tick_target(tick_target) {} | 58 : interval(interval), tick_target(tick_target) {} |
53 base::TimeDelta interval; | 59 base::TimeDelta interval; |
54 base::TimeTicks tick_target; | 60 base::TimeTicks tick_target; |
55 }; | 61 }; |
56 | 62 |
57 TimeSourceClient* client_; | 63 TimeSourceClient* client_; |
| 64 bool has_tick_target_; |
58 base::TimeTicks last_tick_time_; | 65 base::TimeTicks last_tick_time_; |
59 | 66 |
60 // current_parameters_ should only be written by PostNextTickTask. | 67 // current_parameters_ should only be written by PostNextTickTask. |
61 // next_parameters_ will take effect on the next call to PostNextTickTask. | 68 // next_parameters_ will take effect on the next call to PostNextTickTask. |
62 // Maintaining a pending set of parameters allows NextTickTime() to always | 69 // Maintaining a pending set of parameters allows NextTickTime() to always |
63 // reflect the actual time we expect OnTimerFired to be called. | 70 // reflect the actual time we expect OnTimerFired to be called. |
64 Parameters current_parameters_; | 71 Parameters current_parameters_; |
65 Parameters next_parameters_; | 72 Parameters next_parameters_; |
66 | 73 |
67 bool active_; | 74 State state_; |
68 | 75 |
69 base::SingleThreadTaskRunner* task_runner_; | 76 base::SingleThreadTaskRunner* task_runner_; |
70 base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_; | 77 base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_; |
71 | 78 |
72 private: | 79 private: |
73 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSource); | 80 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSource); |
74 }; | 81 }; |
75 | 82 |
76 } // namespace cc | 83 } // namespace cc |
77 | 84 |
78 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ | 85 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ |
OLD | NEW |