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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/test/scheduler_test_common.cc » ('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 #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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "cc/scheduler/compositor_timing_history.h" 16 #include "cc/scheduler/compositor_timing_history.h"
16 #include "cc/scheduler/scheduler.h" 17 #include "cc/scheduler/scheduler.h"
17 #include "cc/test/ordered_simple_task_runner.h" 18 #include "cc/test/ordered_simple_task_runner.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace cc { 21 namespace cc {
21 22
22 class RenderingStatsInstrumentation; 23 class RenderingStatsInstrumentation;
23 24
24 class FakeDelayBasedTimeSourceClient : public DelayBasedTimeSourceClient { 25 class FakeDelayBasedTimeSourceClient : public DelayBasedTimeSourceClient {
25 public: 26 public:
26 FakeDelayBasedTimeSourceClient() : tick_called_(false) {} 27 FakeDelayBasedTimeSourceClient() : tick_called_(false) {}
27 void Reset() { tick_called_ = false; } 28 void Reset() { tick_called_ = false; }
28 bool TickCalled() const { return tick_called_; } 29 bool TickCalled() const { return tick_called_; }
29 30
30 // DelayBasedTimeSourceClient implementation. 31 // DelayBasedTimeSourceClient implementation.
31 void OnTimerTick() override; 32 void OnTimerTick() override;
32 33
33 protected: 34 protected:
34 bool tick_called_; 35 bool tick_called_;
35 36
36 private: 37 private:
37 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient); 38 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient);
38 }; 39 };
39 40
40 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { 41 class FakeDelayBasedTimeSource : public DelayBasedTimeSource {
41 public: 42 public:
42 static scoped_ptr<FakeDelayBasedTimeSource> Create( 43 static std::unique_ptr<FakeDelayBasedTimeSource> Create(
43 base::TimeDelta interval, 44 base::TimeDelta interval,
44 base::SingleThreadTaskRunner* task_runner) { 45 base::SingleThreadTaskRunner* task_runner) {
45 return make_scoped_ptr(new FakeDelayBasedTimeSource(interval, task_runner)); 46 return base::WrapUnique(
47 new FakeDelayBasedTimeSource(interval, task_runner));
46 } 48 }
47 49
48 ~FakeDelayBasedTimeSource() override {} 50 ~FakeDelayBasedTimeSource() override {}
49 51
50 void SetNow(base::TimeTicks time) { now_ = time; } 52 void SetNow(base::TimeTicks time) { now_ = time; }
51 base::TimeTicks Now() const override; 53 base::TimeTicks Now() const override;
52 54
53 protected: 55 protected:
54 FakeDelayBasedTimeSource(base::TimeDelta interval, 56 FakeDelayBasedTimeSource(base::TimeDelta interval,
55 base::SingleThreadTaskRunner* task_runner) 57 base::SingleThreadTaskRunner* task_runner)
56 : DelayBasedTimeSource(interval, task_runner) {} 58 : DelayBasedTimeSource(interval, task_runner) {}
57 59
58 base::TimeTicks now_; 60 base::TimeTicks now_;
59 61
60 private: 62 private:
61 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); 63 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource);
62 }; 64 };
63 65
64 class TestDelayBasedTimeSource : public DelayBasedTimeSource { 66 class TestDelayBasedTimeSource : public DelayBasedTimeSource {
65 public: 67 public:
66 static scoped_ptr<TestDelayBasedTimeSource> Create( 68 static std::unique_ptr<TestDelayBasedTimeSource> Create(
67 base::SimpleTestTickClock* now_src, 69 base::SimpleTestTickClock* now_src,
68 base::TimeDelta interval, 70 base::TimeDelta interval,
69 OrderedSimpleTaskRunner* task_runner) { 71 OrderedSimpleTaskRunner* task_runner) {
70 return make_scoped_ptr( 72 return base::WrapUnique(
71 new TestDelayBasedTimeSource(now_src, interval, task_runner)); 73 new TestDelayBasedTimeSource(now_src, interval, task_runner));
72 } 74 }
73 75
74 ~TestDelayBasedTimeSource() override; 76 ~TestDelayBasedTimeSource() override;
75 77
76 protected: 78 protected:
77 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src, 79 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src,
78 base::TimeDelta interval, 80 base::TimeDelta interval,
79 OrderedSimpleTaskRunner* task_runner); 81 OrderedSimpleTaskRunner* task_runner);
80 82
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 OrderedSimpleTaskRunner* task_runner, 139 OrderedSimpleTaskRunner* task_runner,
138 base::TimeDelta initial_interval); 140 base::TimeDelta initial_interval);
139 ~TestSyntheticBeginFrameSource() override; 141 ~TestSyntheticBeginFrameSource() override;
140 142
141 private: 143 private:
142 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); 144 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource);
143 }; 145 };
144 146
145 class FakeCompositorTimingHistory : public CompositorTimingHistory { 147 class FakeCompositorTimingHistory : public CompositorTimingHistory {
146 public: 148 public:
147 static scoped_ptr<FakeCompositorTimingHistory> Create( 149 static std::unique_ptr<FakeCompositorTimingHistory> Create(
148 bool using_synchronous_renderer_compositor); 150 bool using_synchronous_renderer_compositor);
149 ~FakeCompositorTimingHistory() override; 151 ~FakeCompositorTimingHistory() override;
150 152
151 void SetAllEstimatesTo(base::TimeDelta duration); 153 void SetAllEstimatesTo(base::TimeDelta duration);
152 154
153 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); 155 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration);
154 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration); 156 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration);
155 void SetBeginMainFrameQueueDurationNotCriticalEstimate( 157 void SetBeginMainFrameQueueDurationNotCriticalEstimate(
156 base::TimeDelta duration); 158 base::TimeDelta duration);
157 void SetBeginMainFrameStartToCommitDurationEstimate(base::TimeDelta duration); 159 void SetBeginMainFrameStartToCommitDurationEstimate(base::TimeDelta duration);
158 void SetCommitToReadyToActivateDurationEstimate(base::TimeDelta duration); 160 void SetCommitToReadyToActivateDurationEstimate(base::TimeDelta duration);
159 void SetPrepareTilesDurationEstimate(base::TimeDelta duration); 161 void SetPrepareTilesDurationEstimate(base::TimeDelta duration);
160 void SetActivateDurationEstimate(base::TimeDelta duration); 162 void SetActivateDurationEstimate(base::TimeDelta duration);
161 void SetDrawDurationEstimate(base::TimeDelta duration); 163 void SetDrawDurationEstimate(base::TimeDelta duration);
162 164
163 base::TimeDelta BeginMainFrameToCommitDurationEstimate() const override; 165 base::TimeDelta BeginMainFrameToCommitDurationEstimate() const override;
164 base::TimeDelta BeginMainFrameQueueDurationCriticalEstimate() const override; 166 base::TimeDelta BeginMainFrameQueueDurationCriticalEstimate() const override;
165 base::TimeDelta BeginMainFrameQueueDurationNotCriticalEstimate() 167 base::TimeDelta BeginMainFrameQueueDurationNotCriticalEstimate()
166 const override; 168 const override;
167 base::TimeDelta BeginMainFrameStartToCommitDurationEstimate() const override; 169 base::TimeDelta BeginMainFrameStartToCommitDurationEstimate() const override;
168 base::TimeDelta CommitToReadyToActivateDurationEstimate() const override; 170 base::TimeDelta CommitToReadyToActivateDurationEstimate() const override;
169 base::TimeDelta PrepareTilesDurationEstimate() const override; 171 base::TimeDelta PrepareTilesDurationEstimate() const override;
170 base::TimeDelta ActivateDurationEstimate() const override; 172 base::TimeDelta ActivateDurationEstimate() const override;
171 base::TimeDelta DrawDurationEstimate() const override; 173 base::TimeDelta DrawDurationEstimate() const override;
172 174
173 protected: 175 protected:
174 FakeCompositorTimingHistory(bool using_synchronous_renderer_compositor, 176 FakeCompositorTimingHistory(bool using_synchronous_renderer_compositor,
175 scoped_ptr<RenderingStatsInstrumentation> 177 std::unique_ptr<RenderingStatsInstrumentation>
176 rendering_stats_instrumentation_owned); 178 rendering_stats_instrumentation_owned);
177 179
178 scoped_ptr<RenderingStatsInstrumentation> 180 std::unique_ptr<RenderingStatsInstrumentation>
179 rendering_stats_instrumentation_owned_; 181 rendering_stats_instrumentation_owned_;
180 182
181 base::TimeDelta begin_main_frame_to_commit_duration_; 183 base::TimeDelta begin_main_frame_to_commit_duration_;
182 base::TimeDelta begin_main_frame_queue_duration_critical_; 184 base::TimeDelta begin_main_frame_queue_duration_critical_;
183 base::TimeDelta begin_main_frame_queue_duration_not_critical_; 185 base::TimeDelta begin_main_frame_queue_duration_not_critical_;
184 base::TimeDelta begin_main_frame_start_to_commit_duration_; 186 base::TimeDelta begin_main_frame_start_to_commit_duration_;
185 base::TimeDelta commit_to_ready_to_activate_duration_; 187 base::TimeDelta commit_to_ready_to_activate_duration_;
186 base::TimeDelta prepare_tiles_duration_; 188 base::TimeDelta prepare_tiles_duration_;
187 base::TimeDelta activate_duration_; 189 base::TimeDelta activate_duration_;
188 base::TimeDelta draw_duration_; 190 base::TimeDelta draw_duration_;
189 191
190 private: 192 private:
191 DISALLOW_COPY_AND_ASSIGN(FakeCompositorTimingHistory); 193 DISALLOW_COPY_AND_ASSIGN(FakeCompositorTimingHistory);
192 }; 194 };
193 195
194 class TestScheduler : public Scheduler { 196 class TestScheduler : public Scheduler {
195 public: 197 public:
196 TestScheduler(base::SimpleTestTickClock* now_src, 198 TestScheduler(
197 SchedulerClient* client, 199 base::SimpleTestTickClock* now_src,
198 const SchedulerSettings& scheduler_settings, 200 SchedulerClient* client,
199 int layer_tree_host_id, 201 const SchedulerSettings& scheduler_settings,
200 OrderedSimpleTaskRunner* task_runner, 202 int layer_tree_host_id,
201 BeginFrameSource* begin_frame_source, 203 OrderedSimpleTaskRunner* task_runner,
202 scoped_ptr<CompositorTimingHistory> compositor_timing_history); 204 BeginFrameSource* begin_frame_source,
205 std::unique_ptr<CompositorTimingHistory> compositor_timing_history);
203 206
204 // Extra test helper functionality 207 // Extra test helper functionality
205 bool IsBeginRetroFrameArgsEmpty() const { 208 bool IsBeginRetroFrameArgsEmpty() const {
206 return begin_retro_frame_args_.empty(); 209 return begin_retro_frame_args_.empty();
207 } 210 }
208 211
209 bool SwapThrottled() const { return state_machine_.SwapThrottled(); } 212 bool SwapThrottled() const { return state_machine_.SwapThrottled(); }
210 213
211 bool NeedsBeginMainFrame() const { 214 bool NeedsBeginMainFrame() const {
212 return state_machine_.needs_begin_main_frame(); 215 return state_machine_.needs_begin_main_frame();
(...skipping 29 matching lines...) Expand all
242 245
243 private: 246 private:
244 base::SimpleTestTickClock* now_src_; 247 base::SimpleTestTickClock* now_src_;
245 248
246 DISALLOW_COPY_AND_ASSIGN(TestScheduler); 249 DISALLOW_COPY_AND_ASSIGN(TestScheduler);
247 }; 250 };
248 251
249 } // namespace cc 252 } // namespace cc
250 253
251 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ 254 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/test/scheduler_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698