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 "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 5 #include "components/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 "components/scheduler/child/web_scheduler_impl.h" | 9 #include "components/scheduler/child/web_scheduler_impl.h" |
10 #include "components/scheduler/child/worker_scheduler_impl.h" | 10 #include "components/scheduler/child/worker_scheduler_impl.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } // namespace | 86 } // namespace |
87 | 87 |
88 class WebThreadImplForWorkerSchedulerTest : public testing::Test { | 88 class WebThreadImplForWorkerSchedulerTest : public testing::Test { |
89 public: | 89 public: |
90 WebThreadImplForWorkerSchedulerTest() {} | 90 WebThreadImplForWorkerSchedulerTest() {} |
91 | 91 |
92 ~WebThreadImplForWorkerSchedulerTest() override {} | 92 ~WebThreadImplForWorkerSchedulerTest() override {} |
93 | 93 |
94 void SetUp() override { | 94 void SetUp() override { |
95 thread_.reset(new WebThreadImplForWorkerScheduler("test thread")); | 95 thread_.reset(new WebThreadImplForWorkerScheduler("test thread")); |
| 96 thread_->Init(); |
96 } | 97 } |
97 | 98 |
98 void RunOnWorkerThread(const tracked_objects::Location& from_here, | 99 void RunOnWorkerThread(const tracked_objects::Location& from_here, |
99 const base::Closure& task) { | 100 const base::Closure& task) { |
100 base::WaitableEvent completion(false, false); | 101 base::WaitableEvent completion(false, false); |
101 thread_->TaskRunner()->PostTask( | 102 thread_->TaskRunner()->PostTask( |
102 from_here, | 103 from_here, |
103 base::Bind(&WebThreadImplForWorkerSchedulerTest::RunOnWorkerThreadTask, | 104 base::Bind(&WebThreadImplForWorkerSchedulerTest::RunOnWorkerThreadTask, |
104 base::Unretained(this), task, &completion)); | 105 base::Unretained(this), task, &completion)); |
105 completion.Wait(); | 106 completion.Wait(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 EXPECT_CALL(*delayed_task, run()).Times(0); | 186 EXPECT_CALL(*delayed_task, run()).Times(0); |
186 | 187 |
187 RunOnWorkerThread(FROM_HERE, base::Bind(&shutdownOnThread, thread_.get())); | 188 RunOnWorkerThread(FROM_HERE, base::Bind(&shutdownOnThread, thread_.get())); |
188 thread_->taskRunner()->postTask(blink::WebTraceLocation(), task.release()); | 189 thread_->taskRunner()->postTask(blink::WebTraceLocation(), task.release()); |
189 thread_->taskRunner()->postDelayedTask(blink::WebTraceLocation(), | 190 thread_->taskRunner()->postDelayedTask(blink::WebTraceLocation(), |
190 task.release(), 50ll); | 191 task.release(), 50ll); |
191 thread_.reset(); | 192 thread_.reset(); |
192 } | 193 } |
193 | 194 |
194 } // namespace scheduler | 195 } // namespace scheduler |
OLD | NEW |