OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "platform/scheduler/Scheduler.h" | 6 #include "platform/scheduler/Scheduler.h" |
7 | 7 |
8 #include "platform/TestingPlatformSupport.h" | 8 #include "platform/TestingPlatformSupport.h" |
9 #include "platform/TraceLocation.h" | 9 #include "platform/TraceLocation.h" |
10 #include "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 using Scheduler::Normal; | 29 using Scheduler::Normal; |
30 using Scheduler::CompositorPriority; | 30 using Scheduler::CompositorPriority; |
31 using Scheduler::enterSchedulerPolicy; | 31 using Scheduler::enterSchedulerPolicy; |
32 }; | 32 }; |
33 | 33 |
34 class TestMainThread : public blink::WebThread { | 34 class TestMainThread : public blink::WebThread { |
35 public: | 35 public: |
36 // blink::WebThread implementation. | 36 // blink::WebThread implementation. |
37 virtual void postTask(Task* task) OVERRIDE | 37 virtual void postTask(Task* task) override |
38 { | 38 { |
39 m_pendingTasks.append(adoptPtr(task)); | 39 m_pendingTasks.append(adoptPtr(task)); |
40 } | 40 } |
41 | 41 |
42 virtual void postDelayedTask(Task* task, long long delayMs) OVERRIDE | 42 virtual void postDelayedTask(Task* task, long long delayMs) override |
43 { | 43 { |
44 ASSERT_NOT_REACHED(); | 44 ASSERT_NOT_REACHED(); |
45 } | 45 } |
46 | 46 |
47 virtual bool isCurrentThread() const OVERRIDE | 47 virtual bool isCurrentThread() const override |
48 { | 48 { |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 virtual blink::PlatformThreadId threadId() const OVERRIDE | 52 virtual blink::PlatformThreadId threadId() const override |
53 { | 53 { |
54 ASSERT_NOT_REACHED(); | 54 ASSERT_NOT_REACHED(); |
55 return 0; | 55 return 0; |
56 } | 56 } |
57 | 57 |
58 virtual void enterRunLoop() OVERRIDE | 58 virtual void enterRunLoop() override |
59 { | 59 { |
60 ASSERT_NOT_REACHED(); | 60 ASSERT_NOT_REACHED(); |
61 } | 61 } |
62 | 62 |
63 virtual void exitRunLoop() OVERRIDE | 63 virtual void exitRunLoop() override |
64 { | 64 { |
65 ASSERT_NOT_REACHED(); | 65 ASSERT_NOT_REACHED(); |
66 } | 66 } |
67 | 67 |
68 void runPendingTasks() | 68 void runPendingTasks() |
69 { | 69 { |
70 while (!m_pendingTasks.isEmpty()) | 70 while (!m_pendingTasks.isEmpty()) |
71 m_pendingTasks.takeFirst()->run(); | 71 m_pendingTasks.takeFirst()->run(); |
72 } | 72 } |
73 | 73 |
(...skipping 11 matching lines...) Expand all Loading... |
85 SchedulerTestingPlatformSupport() | 85 SchedulerTestingPlatformSupport() |
86 : TestingPlatformSupport(TestingPlatformSupport::Config()) | 86 : TestingPlatformSupport(TestingPlatformSupport::Config()) |
87 , m_sharedTimerFunction(nullptr) | 87 , m_sharedTimerFunction(nullptr) |
88 , m_sharedTimerRunning(false) | 88 , m_sharedTimerRunning(false) |
89 , m_sharedTimerFireInterval(0) | 89 , m_sharedTimerFireInterval(0) |
90 , m_monotonicallyIncreasingTime(0) | 90 , m_monotonicallyIncreasingTime(0) |
91 { | 91 { |
92 } | 92 } |
93 | 93 |
94 // blink::Platform implementation. | 94 // blink::Platform implementation. |
95 virtual blink::WebThread* currentThread() OVERRIDE | 95 virtual blink::WebThread* currentThread() override |
96 { | 96 { |
97 return &m_mainThread; | 97 return &m_mainThread; |
98 } | 98 } |
99 | 99 |
100 virtual void setSharedTimerFiredFunction(SharedTimerFunction timerFunction)
OVERRIDE | 100 virtual void setSharedTimerFiredFunction(SharedTimerFunction timerFunction)
override |
101 { | 101 { |
102 m_sharedTimerFunction = timerFunction; | 102 m_sharedTimerFunction = timerFunction; |
103 } | 103 } |
104 | 104 |
105 virtual double monotonicallyIncreasingTime() OVERRIDE | 105 virtual double monotonicallyIncreasingTime() override |
106 { | 106 { |
107 return m_monotonicallyIncreasingTime; | 107 return m_monotonicallyIncreasingTime; |
108 } | 108 } |
109 | 109 |
110 virtual void setSharedTimerFireInterval(double) | 110 virtual void setSharedTimerFireInterval(double) |
111 { | 111 { |
112 m_sharedTimerFireInterval = 0; | 112 m_sharedTimerFireInterval = 0; |
113 m_sharedTimerRunning = true; | 113 m_sharedTimerRunning = true; |
114 } | 114 } |
115 | 115 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 { | 164 { |
165 SchedulerForTest::initializeOnMainThread(); | 165 SchedulerForTest::initializeOnMainThread(); |
166 m_scheduler = static_cast<SchedulerForTest*>(Scheduler::shared()); | 166 m_scheduler = static_cast<SchedulerForTest*>(Scheduler::shared()); |
167 } | 167 } |
168 | 168 |
169 ~SchedulerTest() | 169 ~SchedulerTest() |
170 { | 170 { |
171 Scheduler::shutdown(); | 171 Scheduler::shutdown(); |
172 } | 172 } |
173 | 173 |
174 virtual void SetUp() OVERRIDE | 174 virtual void SetUp() override |
175 { | 175 { |
176 m_scheduler->enterSchedulerPolicy(SchedulerForTest::Normal); | 176 m_scheduler->enterSchedulerPolicy(SchedulerForTest::Normal); |
177 } | 177 } |
178 | 178 |
179 virtual void TearDown() OVERRIDE | 179 virtual void TearDown() override |
180 { | 180 { |
181 // If the Scheduler hasn't been shut down then explicitly flush the task
s. | 181 // If the Scheduler hasn't been shut down then explicitly flush the task
s. |
182 if (Scheduler::shared()) | 182 if (Scheduler::shared()) |
183 runPendingTasks(); | 183 runPendingTasks(); |
184 } | 184 } |
185 | 185 |
186 void runPendingTasks() | 186 void runPendingTasks() |
187 { | 187 { |
188 m_platformSupport.runPendingTasks(); | 188 m_platformSupport.runPendingTasks(); |
189 } | 189 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 m_platformSupport.setMonotonicTimeForTest(1000.5); | 530 m_platformSupport.setMonotonicTimeForTest(1000.5); |
531 runPendingTasks(); | 531 runPendingTasks(); |
532 | 532 |
533 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); | 533 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); |
534 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); | 534 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); |
535 | 535 |
536 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); | 536 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); |
537 } | 537 } |
538 | 538 |
539 } // namespace | 539 } // namespace |
OLD | NEW |