OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/scheduler/child/webthread_impl_for_worker_scheduler.h" | 5 #include "platform/scheduler/child/webthread_impl_for_worker_scheduler.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "platform/WebTaskRunner.h" | 9 #include "platform/WebTaskRunner.h" |
10 #include "platform/scheduler/child/web_scheduler_impl.h" | 10 #include "platform/scheduler/child/web_scheduler_impl.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 144 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
145 base::WaitableEvent::InitialState::NOT_SIGNALED); | 145 base::WaitableEvent::InitialState::NOT_SIGNALED); |
146 | 146 |
147 EXPECT_CALL(*task, Run(_)); | 147 EXPECT_CALL(*task, Run(_)); |
148 ON_CALL(*task, Run(_)).WillByDefault(Invoke([&completion](double) { | 148 ON_CALL(*task, Run(_)).WillByDefault(Invoke([&completion](double) { |
149 completion.Signal(); | 149 completion.Signal(); |
150 })); | 150 })); |
151 | 151 |
152 thread_->PostIdleTask(BLINK_FROM_HERE, task.release()); | 152 thread_->PostIdleTask(BLINK_FROM_HERE, task.release()); |
153 // We need to post a wake-up task or idle work will never happen. | 153 // We need to post a wake-up task or idle work will never happen. |
154 thread_->GetWebTaskRunner()->PostDelayedTask(BLINK_FROM_HERE, | 154 thread_->GetWebTaskRunner()->PostDelayedTask( |
155 WTF::Bind([] {}), 50ll); | 155 BLINK_FROM_HERE, WTF::Bind([] {}), TimeDelta::FromMilliseconds(50)); |
156 | 156 |
157 completion.Wait(); | 157 completion.Wait(); |
158 } | 158 } |
159 | 159 |
160 TEST_F(WebThreadImplForWorkerSchedulerTest, TestTaskObserver) { | 160 TEST_F(WebThreadImplForWorkerSchedulerTest, TestTaskObserver) { |
161 std::string calls; | 161 std::string calls; |
162 TestObserver observer(&calls); | 162 TestObserver observer(&calls); |
163 | 163 |
164 RunOnWorkerThread(FROM_HERE, | 164 RunOnWorkerThread(FROM_HERE, |
165 base::Bind(&AddTaskObserver, thread_.get(), &observer)); | 165 base::Bind(&AddTaskObserver, thread_.get(), &observer)); |
(...skipping 15 matching lines...) Expand all Loading... |
181 MockTask delayed_task; | 181 MockTask delayed_task; |
182 | 182 |
183 EXPECT_CALL(task, Run()).Times(0); | 183 EXPECT_CALL(task, Run()).Times(0); |
184 EXPECT_CALL(delayed_task, Run()).Times(0); | 184 EXPECT_CALL(delayed_task, Run()).Times(0); |
185 | 185 |
186 RunOnWorkerThread(FROM_HERE, base::Bind(&ShutdownOnThread, thread_.get())); | 186 RunOnWorkerThread(FROM_HERE, base::Bind(&ShutdownOnThread, thread_.get())); |
187 thread_->GetWebTaskRunner()->PostTask( | 187 thread_->GetWebTaskRunner()->PostTask( |
188 BLINK_FROM_HERE, WTF::Bind(&MockTask::Run, WTF::Unretained(&task))); | 188 BLINK_FROM_HERE, WTF::Bind(&MockTask::Run, WTF::Unretained(&task))); |
189 thread_->GetWebTaskRunner()->PostDelayedTask( | 189 thread_->GetWebTaskRunner()->PostDelayedTask( |
190 BLINK_FROM_HERE, | 190 BLINK_FROM_HERE, |
191 WTF::Bind(&MockTask::Run, WTF::Unretained(&delayed_task)), 50ll); | 191 WTF::Bind(&MockTask::Run, WTF::Unretained(&delayed_task)), |
| 192 TimeDelta::FromMilliseconds(50)); |
192 thread_.reset(); | 193 thread_.reset(); |
193 } | 194 } |
194 | 195 |
195 } // namespace scheduler | 196 } // namespace scheduler |
196 } // namespace blink | 197 } // namespace blink |
OLD | NEW |