• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "cc/test/scheduler_test_common.h"
6 
7 #include <string>
8 
9 #include "base/logging.h"
10 
11 namespace cc {
12 
OnTimerTick()13 void FakeTimeSourceClient::OnTimerTick() {
14   tick_called_ = true;
15 }
16 
Now() const17 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
18 
TestDelayBasedTimeSource(scoped_refptr<TestNowSource> now_src,base::TimeDelta interval,OrderedSimpleTaskRunner * task_runner)19 TestDelayBasedTimeSource::TestDelayBasedTimeSource(
20     scoped_refptr<TestNowSource> now_src,
21     base::TimeDelta interval,
22     OrderedSimpleTaskRunner* task_runner)
23     : DelayBasedTimeSource(interval, task_runner), now_src_(now_src) {
24 }
25 
Now() const26 base::TimeTicks TestDelayBasedTimeSource::Now() const {
27   return now_src_->Now();
28 }
29 
TypeString() const30 std::string TestDelayBasedTimeSource::TypeString() const {
31   return "TestDelayBasedTimeSource";
32 }
33 
~TestDelayBasedTimeSource()34 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {
35 }
36 
TestScheduler(scoped_refptr<TestNowSource> now_src,SchedulerClient * client,const SchedulerSettings & scheduler_settings,int layer_tree_host_id,const scoped_refptr<OrderedSimpleTaskRunner> & test_task_runner)37 TestScheduler::TestScheduler(
38     scoped_refptr<TestNowSource> now_src,
39     SchedulerClient* client,
40     const SchedulerSettings& scheduler_settings,
41     int layer_tree_host_id,
42     const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner)
43     : Scheduler(client,
44                 scheduler_settings,
45                 layer_tree_host_id,
46                 test_task_runner),
47       now_src_(now_src),
48       test_task_runner_(test_task_runner.get()) {
49   if (!settings_.begin_frame_scheduling_enabled) {
50     scoped_refptr<DelayBasedTimeSource> time_source =
51         TestDelayBasedTimeSource::Create(
52             now_src, VSyncInterval(), test_task_runner_);
53     synthetic_begin_frame_source_.reset(
54         new SyntheticBeginFrameSource(this, time_source));
55   }
56 }
57 
Now() const58 base::TimeTicks TestScheduler::Now() const {
59   return now_src_->Now();
60 }
61 
~TestScheduler()62 TestScheduler::~TestScheduler() {
63 }
64 
65 }  // namespace cc
66