| 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> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "cc/base/cc_export.h" | |
| 13 | 12 |
| 14 namespace base { | 13 namespace base { |
| 15 namespace trace_event { | 14 namespace trace_event { |
| 16 class TracedValue; | 15 class TracedValue; |
| 17 } | 16 } |
| 18 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace cc { | 20 namespace cc { |
| 22 | 21 |
| 23 class CC_EXPORT TimeSourceClient { | 22 class TimeSourceClient { |
| 24 public: | 23 public: |
| 25 virtual void OnTimerTick() = 0; | 24 virtual void OnTimerTick() = 0; |
| 26 | 25 |
| 27 protected: | 26 protected: |
| 28 virtual ~TimeSourceClient() {} | 27 virtual ~TimeSourceClient() {} |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 // This timer implements a time source that achieves the specified interval | 30 // This timer implements a time source that achieves the specified interval |
| 32 // in face of millisecond-precision delayed callbacks and random queueing | 31 // in face of millisecond-precision delayed callbacks and random queueing |
| 33 // delays. DelayBasedTimeSource uses base::TimeTicks::Now as its timebase. | 32 // delays. DelayBasedTimeSource uses base::TimeTicks::Now as its timebase. |
| 34 class CC_EXPORT DelayBasedTimeSource | 33 class DelayBasedTimeSource : public base::RefCounted<DelayBasedTimeSource> { |
| 35 : public base::RefCounted<DelayBasedTimeSource> { | |
| 36 public: | 34 public: |
| 37 static scoped_refptr<DelayBasedTimeSource> Create( | 35 static scoped_refptr<DelayBasedTimeSource> Create( |
| 38 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); | 36 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); |
| 39 | 37 |
| 40 virtual void SetClient(TimeSourceClient* client); | 38 virtual void SetClient(TimeSourceClient* client); |
| 41 | 39 |
| 42 // TimeSource implementation | 40 // TimeSource implementation |
| 43 virtual void SetTimebaseAndInterval(base::TimeTicks timebase, | 41 virtual void SetTimebaseAndInterval(base::TimeTicks timebase, |
| 44 base::TimeDelta interval); | 42 base::TimeDelta interval); |
| 45 base::TimeDelta Interval() const { return next_parameters_.interval; } | 43 base::TimeDelta Interval() const { return next_parameters_.interval; } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 110 |
| 113 std::string TypeString() const override; | 111 std::string TypeString() const override; |
| 114 | 112 |
| 115 private: | 113 private: |
| 116 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSourceHighRes); | 114 DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSourceHighRes); |
| 117 }; | 115 }; |
| 118 | 116 |
| 119 } // namespace cc | 117 } // namespace cc |
| 120 | 118 |
| 121 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ | 119 #endif // CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ |
| OLD | NEW |