Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: cc/scheduler/delay_based_time_source.h

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scheduler tests now pass and the code is cleaner. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/scheduler/delay_based_time_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/scheduler/delay_based_time_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698