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

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 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/scheduler/delay_based_time_source.h ('k') | cc/scheduler/frame_source.h » ('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 #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 #include <string>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 16
16 namespace cc { 17 namespace cc {
17 18
18 namespace { 19 namespace {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (last_tick_time_if_always_active > new_tick_time_threshold) { 99 if (last_tick_time_if_always_active > new_tick_time_threshold) {
99 last_tick_time_ = last_tick_time_if_always_active; 100 last_tick_time_ = last_tick_time_if_always_active;
100 return last_tick_time_; 101 return last_tick_time_;
101 } 102 }
102 103
103 return base::TimeTicks(); 104 return base::TimeTicks();
104 } 105 }
105 106
106 bool DelayBasedTimeSource::Active() const { return active_; } 107 bool DelayBasedTimeSource::Active() const { return active_; }
107 108
108 base::TimeTicks DelayBasedTimeSource::LastTickTime() { return last_tick_time_; } 109 base::TimeTicks DelayBasedTimeSource::LastTickTime() const {
110 return last_tick_time_;
111 }
109 112
110 base::TimeTicks DelayBasedTimeSource::NextTickTime() { 113 base::TimeTicks DelayBasedTimeSource::NextTickTime() const {
111 return Active() ? current_parameters_.tick_target : base::TimeTicks(); 114 return Active() ? current_parameters_.tick_target : base::TimeTicks();
112 } 115 }
113 116
114 void DelayBasedTimeSource::OnTimerFired() { 117 void DelayBasedTimeSource::OnTimerFired() {
115 DCHECK(active_); 118 DCHECK(active_);
116 119
117 last_tick_time_ = current_parameters_.tick_target; 120 last_tick_time_ = current_parameters_.tick_target;
118 121
119 PostNextTickTask(Now()); 122 PostNextTickTask(Now());
120 123
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 delay = new_tick_target - now; 274 delay = new_tick_target - now;
272 task_runner_->PostDelayedTask(FROM_HERE, 275 task_runner_->PostDelayedTask(FROM_HERE,
273 base::Bind(&DelayBasedTimeSource::OnTimerFired, 276 base::Bind(&DelayBasedTimeSource::OnTimerFired,
274 weak_factory_.GetWeakPtr()), 277 weak_factory_.GetWeakPtr()),
275 delay); 278 delay);
276 279
277 next_parameters_.tick_target = new_tick_target; 280 next_parameters_.tick_target = new_tick_target;
278 current_parameters_ = next_parameters_; 281 current_parameters_ = next_parameters_;
279 } 282 }
280 283
284 std::string DelayBasedTimeSource::TypeString() const {
285 return "DelayBasedTimeSource";
286 }
287
288 std::string DelayBasedTimeSourceHighRes::TypeString() const {
289 return "DelayBasedTimeSourceHighRes";
290 }
291
292 scoped_ptr<base::Value> DelayBasedTimeSource::AsValue() const {
293 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
294 state->SetString("type", TypeString());
295 state->SetDouble("last_tick_time_us", LastTickTime().ToInternalValue());
296 state->SetDouble("next_tick_time_us", NextTickTime().ToInternalValue());
297
298 scoped_ptr<base::DictionaryValue> state_current_parameters(
299 new base::DictionaryValue);
300 state_current_parameters->SetDouble(
301 "interval_us", current_parameters_.interval.InMicroseconds());
302 state_current_parameters->SetDouble(
303 "tick_target_us", current_parameters_.tick_target.ToInternalValue());
304 state->Set("current_parameters", state_current_parameters.release());
305
306 scoped_ptr<base::DictionaryValue> state_next_parameters(
307 new base::DictionaryValue);
308 state_next_parameters->SetDouble("interval_us",
309 next_parameters_.interval.InMicroseconds());
310 state_next_parameters->SetDouble(
311 "tick_target_us", next_parameters_.tick_target.ToInternalValue());
312 state->Set("next_parameters", state_next_parameters.release());
313
314 state->SetBoolean("active", active_);
315
316 return state.PassAs<base::Value>();
317 }
318
281 } // namespace cc 319 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/delay_based_time_source.h ('k') | cc/scheduler/frame_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698