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

Side by Side Diff: cc/test/scheduler_test_common.h

Issue 1200113003: cc: Cleanup DelayBasedTimeSource code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_runner_refptr
Patch Set: Fix race between missed tick and normal tick Created 5 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
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_TEST_SCHEDULER_TEST_COMMON_H_ 5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_
6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ 6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "cc/scheduler/compositor_timing_history.h" 13 #include "cc/scheduler/compositor_timing_history.h"
14 #include "cc/scheduler/scheduler.h" 14 #include "cc/scheduler/scheduler.h"
15 #include "cc/test/ordered_simple_task_runner.h" 15 #include "cc/test/ordered_simple_task_runner.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 class RenderingStatsInstrumentation; 20 class RenderingStatsInstrumentation;
21 21
22 class FakeTimeSourceClient : public TimeSourceClient { 22 class FakeDelayBasedTimeSourceClient : public DelayBasedTimeSourceClient {
23 public: 23 public:
24 FakeTimeSourceClient() : tick_called_(false) {} 24 FakeDelayBasedTimeSourceClient() : tick_called_(false) {}
25 void Reset() { tick_called_ = false; } 25 void Reset() { tick_called_ = false; }
26 bool TickCalled() const { return tick_called_; } 26 bool TickCalled() const { return tick_called_; }
27 27
28 // TimeSourceClient implementation. 28 // DelayBasedTimeSourceClient implementation.
29 void OnMissedTick() override;
29 void OnTimerTick() override; 30 void OnTimerTick() override;
30 31
31 protected: 32 protected:
32 bool tick_called_; 33 bool tick_called_;
33 34
34 private: 35 private:
35 DISALLOW_COPY_AND_ASSIGN(FakeTimeSourceClient); 36 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient);
36 }; 37 };
37 38
38 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { 39 class FakeDelayBasedTimeSource : public DelayBasedTimeSource {
39 public: 40 public:
40 static scoped_ptr<FakeDelayBasedTimeSource> Create( 41 static scoped_ptr<FakeDelayBasedTimeSource> Create(
41 base::TimeDelta interval, 42 base::TimeDelta interval,
42 base::SingleThreadTaskRunner* task_runner) { 43 base::SingleThreadTaskRunner* task_runner) {
43 return make_scoped_ptr(new FakeDelayBasedTimeSource(interval, task_runner)); 44 return make_scoped_ptr(new FakeDelayBasedTimeSource(interval, task_runner));
44 } 45 }
45 46
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ~TestSyntheticBeginFrameSource() override; 144 ~TestSyntheticBeginFrameSource() override;
144 145
145 static scoped_ptr<TestSyntheticBeginFrameSource> Create( 146 static scoped_ptr<TestSyntheticBeginFrameSource> Create(
146 base::SimpleTestTickClock* now_src, 147 base::SimpleTestTickClock* now_src,
147 OrderedSimpleTaskRunner* task_runner, 148 OrderedSimpleTaskRunner* task_runner,
148 base::TimeDelta initial_interval) { 149 base::TimeDelta initial_interval) {
149 scoped_ptr<TestDelayBasedTimeSource> time_source = 150 scoped_ptr<TestDelayBasedTimeSource> time_source =
150 TestDelayBasedTimeSource::Create(now_src, initial_interval, 151 TestDelayBasedTimeSource::Create(now_src, initial_interval,
151 task_runner); 152 task_runner);
152 return make_scoped_ptr( 153 return make_scoped_ptr(
153 new TestSyntheticBeginFrameSource(time_source.Pass())); 154 new TestSyntheticBeginFrameSource(task_runner, time_source.Pass()));
154 } 155 }
155 156
156 protected: 157 protected:
157 explicit TestSyntheticBeginFrameSource( 158 explicit TestSyntheticBeginFrameSource(
159 OrderedSimpleTaskRunner* task_runner,
158 scoped_ptr<DelayBasedTimeSource> time_source); 160 scoped_ptr<DelayBasedTimeSource> time_source);
159 161
160 private: 162 private:
161 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); 163 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource);
162 }; 164 };
163 165
164 class FakeCompositorTimingHistory : public CompositorTimingHistory { 166 class FakeCompositorTimingHistory : public CompositorTimingHistory {
165 public: 167 public:
166 static scoped_ptr<FakeCompositorTimingHistory> Create(); 168 static scoped_ptr<FakeCompositorTimingHistory> Create();
167 ~FakeCompositorTimingHistory() override; 169 ~FakeCompositorTimingHistory() override;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 scoped_ptr<CompositorTimingHistory> compositor_timing_history); 235 scoped_ptr<CompositorTimingHistory> compositor_timing_history);
234 236
235 base::SimpleTestTickClock* now_src_; 237 base::SimpleTestTickClock* now_src_;
236 238
237 DISALLOW_COPY_AND_ASSIGN(TestScheduler); 239 DISALLOW_COPY_AND_ASSIGN(TestScheduler);
238 }; 240 };
239 241
240 } // namespace cc 242 } // namespace cc
241 243
242 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ 244 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698