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

Unified Diff: cc/scheduler/scheduler.cc

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lots of changes. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 52e0f9e093e4dc560c7af23768ef568caf0e9f3b..6e4aebcba470da286859107e3a1e8adcc900184a 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -12,21 +12,13 @@
#include "cc/debug/devtools_instrumentation.h"
#include "cc/debug/traced_value.h"
#include "cc/scheduler/delay_based_time_source.h"
-#include "ui/gfx/frame_time.h"
namespace cc {
Scheduler::SyntheticBeginFrameSource::SyntheticBeginFrameSource(
Scheduler* scheduler,
- base::SingleThreadTaskRunner* task_runner)
- : scheduler_(scheduler) {
- if (gfx::FrameTime::TimestampsAreHighRes()) {
- time_source_ = DelayBasedTimeSourceHighRes::Create(
- scheduler_->VSyncInterval(), task_runner);
- } else {
- time_source_ = DelayBasedTimeSource::Create(scheduler_->VSyncInterval(),
- task_runner);
- }
+ scoped_refptr<DelayBasedTimeSource>& time_source)
+ : scheduler_(scheduler), time_source_(time_source) {
time_source_->SetClient(this);
}
@@ -124,9 +116,21 @@ Scheduler::~Scheduler() {
}
void Scheduler::SetupSyntheticBeginFrames() {
+ scoped_refptr<DelayBasedTimeSource> time_source;
+ if (gfx::FrameTime::TimestampsAreHighRes()) {
+ time_source = DelayBasedTimeSourceHighRes::Create(VSyncInterval(),
+ impl_task_runner_.get());
+ } else {
+ time_source =
+ DelayBasedTimeSource::Create(VSyncInterval(), impl_task_runner_.get());
+ }
DCHECK(!synthetic_begin_frame_source_);
synthetic_begin_frame_source_.reset(
- new SyntheticBeginFrameSource(this, impl_task_runner_.get()));
+ new SyntheticBeginFrameSource(this, time_source));
+}
+
+base::TimeTicks Scheduler::Now() const {
+ return gfx::FrameTime::Now();
}
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
@@ -260,7 +264,7 @@ base::TimeTicks Scheduler::AnticipatedDrawTime() const {
begin_impl_frame_args_.interval <= base::TimeDelta())
return base::TimeTicks();
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
begin_impl_frame_args_.deadline);
int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
@@ -335,7 +339,7 @@ void Scheduler::BeginUnthrottledFrame() {
DCHECK(!settings_.throttle_frame_production);
DCHECK(begin_retro_frame_args_.empty());
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeTicks deadline = now + vsync_interval_;
BeginFrameArgs begin_frame_args =
@@ -446,7 +450,7 @@ void Scheduler::BeginRetroFrame() {
// TODO(brianderson): In the future, long deadlines could result in us not
// draining the queue if we don't catch up. If we consistently can't catch
// up, our fallback should be to lower our frame rate.
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate();
while (!begin_retro_frame_args_.empty() &&
now > AdjustedBeginImplFrameDeadline(begin_retro_frame_args_.front(),
@@ -562,7 +566,7 @@ void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
begin_impl_frame_deadline_task_.Cancel();
begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_);
- base::TimeDelta delta = deadline - gfx::FrameTime::Now();
+ base::TimeDelta delta = deadline - Now();
if (delta <= base::TimeDelta())
delta = base::TimeDelta();
impl_task_runner_->PostDelayedTask(
@@ -688,9 +692,8 @@ scoped_ptr<base::Value> Scheduler::AsValue() const {
synthetic_begin_frame_source_->AsValue().release());
scoped_ptr<base::DictionaryValue> scheduler_state(new base::DictionaryValue);
- scheduler_state->SetDouble(
- "time_until_anticipated_draw_time_ms",
- (AnticipatedDrawTime() - base::TimeTicks::Now()).InMillisecondsF());
+ scheduler_state->SetDouble("time_until_anticipated_draw_time_ms",
+ (AnticipatedDrawTime() - Now()).InMillisecondsF());
scheduler_state->SetDouble("vsync_interval_ms",
vsync_interval_.InMillisecondsF());
scheduler_state->SetDouble("estimated_parent_draw_time_ms",

Powered by Google App Engine
This is Rietveld 408576698