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

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

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scheduler now uses frame sources, working on scheduler_unittests. Created 6 years, 7 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
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 #include "cc/scheduler/delay_based_time_source.h" 5 #include "cc/scheduler/delay_based_time_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 25 matching lines...) Expand all
36 // The following methods correspond to the DelayBasedTimeSource that uses 36 // The following methods correspond to the DelayBasedTimeSource that uses
37 // the base::TimeTicks::HighResNow as the timebase. 37 // the base::TimeTicks::HighResNow as the timebase.
38 scoped_refptr<DelayBasedTimeSourceHighRes> DelayBasedTimeSourceHighRes::Create( 38 scoped_refptr<DelayBasedTimeSourceHighRes> DelayBasedTimeSourceHighRes::Create(
39 base::TimeDelta interval, 39 base::TimeDelta interval,
40 base::SingleThreadTaskRunner* task_runner) { 40 base::SingleThreadTaskRunner* task_runner) {
41 return make_scoped_refptr( 41 return make_scoped_refptr(
42 new DelayBasedTimeSourceHighRes(interval, task_runner)); 42 new DelayBasedTimeSourceHighRes(interval, task_runner));
43 } 43 }
44 44
45 DelayBasedTimeSourceHighRes::DelayBasedTimeSourceHighRes( 45 DelayBasedTimeSourceHighRes::DelayBasedTimeSourceHighRes(
46 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) 46 base::TimeDelta interval,
47 : DelayBasedTimeSource(interval, task_runner) {} 47 base::SingleThreadTaskRunner* task_runner)
48 : DelayBasedTimeSource(interval, task_runner) {
49 }
48 50
49 DelayBasedTimeSourceHighRes::~DelayBasedTimeSourceHighRes() {} 51 DelayBasedTimeSourceHighRes::~DelayBasedTimeSourceHighRes() {}
50 52
51 base::TimeTicks DelayBasedTimeSourceHighRes::Now() const { 53 base::TimeTicks DelayBasedTimeSourceHighRes::Now() const {
52 return base::TimeTicks::HighResNow(); 54 return base::TimeTicks::HighResNow();
53 } 55 }
54 56
55 // The following methods correspond to the DelayBasedTimeSource that uses 57 // The following methods correspond to the DelayBasedTimeSource that uses
56 // the base::TimeTicks::Now as the timebase. 58 // the base::TimeTicks::Now as the timebase.
57 scoped_refptr<DelayBasedTimeSource> DelayBasedTimeSource::Create( 59 scoped_refptr<DelayBasedTimeSource> DelayBasedTimeSource::Create(
58 base::TimeDelta interval, 60 base::TimeDelta interval,
59 base::SingleThreadTaskRunner* task_runner) { 61 base::SingleThreadTaskRunner* task_runner) {
60 return make_scoped_refptr(new DelayBasedTimeSource(interval, task_runner)); 62 return make_scoped_refptr(new DelayBasedTimeSource(interval, task_runner));
61 } 63 }
62 64
63 DelayBasedTimeSource::DelayBasedTimeSource( 65 DelayBasedTimeSource::DelayBasedTimeSource(
64 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) 66 base::TimeDelta interval,
67 base::SingleThreadTaskRunner* task_runner)
65 : client_(NULL), 68 : client_(NULL),
66 last_tick_time_(base::TimeTicks() - interval), 69 last_tick_time_(base::TimeTicks() - interval),
67 current_parameters_(interval, base::TimeTicks()), 70 current_parameters_(interval, base::TimeTicks()),
68 next_parameters_(interval, base::TimeTicks()), 71 next_parameters_(interval, base::TimeTicks()),
69 active_(false), 72 active_(false),
70 task_runner_(task_runner), 73 task_runner_(task_runner),
71 weak_factory_(this) {} 74 weak_factory_(this) {
75 DCHECK_NE(interval.ToInternalValue(), 0);
brianderson 2014/05/07 17:20:16 DCHECK_GE? Below too.
mithro-old 2014/05/07 23:42:28 Done.
76 }
72 77
73 DelayBasedTimeSource::~DelayBasedTimeSource() {} 78 DelayBasedTimeSource::~DelayBasedTimeSource() {}
74 79
75 base::TimeTicks DelayBasedTimeSource::SetActive(bool active) { 80 base::TimeTicks DelayBasedTimeSource::SetActive(bool active) {
76 TRACE_EVENT1("cc", "DelayBasedTimeSource::SetActive", "active", active); 81 TRACE_EVENT1("cc", "DelayBasedTimeSource::SetActive", "active", active);
77 if (active == active_) 82 if (active == active_)
78 return base::TimeTicks(); 83 return base::TimeTicks();
79 active_ = active; 84 active_ = active;
80 85
81 if (!active_) { 86 if (!active_) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (client_) 122 if (client_)
118 client_->OnTimerTick(); 123 client_->OnTimerTick();
119 } 124 }
120 125
121 void DelayBasedTimeSource::SetClient(TimeSourceClient* client) { 126 void DelayBasedTimeSource::SetClient(TimeSourceClient* client) {
122 client_ = client; 127 client_ = client;
123 } 128 }
124 129
125 void DelayBasedTimeSource::SetTimebaseAndInterval(base::TimeTicks timebase, 130 void DelayBasedTimeSource::SetTimebaseAndInterval(base::TimeTicks timebase,
126 base::TimeDelta interval) { 131 base::TimeDelta interval) {
132 DCHECK(!timebase.is_null());
133 DCHECK_NE(interval.ToInternalValue(), 0);
127 next_parameters_.interval = interval; 134 next_parameters_.interval = interval;
128 next_parameters_.tick_target = timebase; 135 next_parameters_.tick_target = timebase;
129 136
130 if (!active_) { 137 if (!active_) {
131 // If we aren't active, there's no need to reset the timer. 138 // If we aren't active, there's no need to reset the timer.
132 return; 139 return;
133 } 140 }
134 141
135 // If the change in interval is larger than the change threshold, 142 // If the change in interval is larger than the change threshold,
136 // request an immediate reset. 143 // request an immediate reset.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 task_runner_->PostDelayedTask(FROM_HERE, 273 task_runner_->PostDelayedTask(FROM_HERE,
267 base::Bind(&DelayBasedTimeSource::OnTimerFired, 274 base::Bind(&DelayBasedTimeSource::OnTimerFired,
268 weak_factory_.GetWeakPtr()), 275 weak_factory_.GetWeakPtr()),
269 delay); 276 delay);
270 277
271 next_parameters_.tick_target = new_tick_target; 278 next_parameters_.tick_target = new_tick_target;
272 current_parameters_ = next_parameters_; 279 current_parameters_ = next_parameters_;
273 } 280 }
274 281
275 } // namespace cc 282 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698