| 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 "public/platform/scheduler/child/webthread_impl_for_worker_scheduler.h" | 5 #include "public/platform/scheduler/child/webthread_impl_for_worker_scheduler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 bool started = thread_->StartWithOptions(options); | 31 bool started = thread_->StartWithOptions(options); |
| 32 CHECK(started); | 32 CHECK(started); |
| 33 thread_task_runner_ = thread_->task_runner(); | 33 thread_task_runner_ = thread_->task_runner(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void WebThreadImplForWorkerScheduler::Init() { | 36 void WebThreadImplForWorkerScheduler::Init() { |
| 37 base::WaitableEvent completion( | 37 base::WaitableEvent completion( |
| 38 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 38 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 39 base::WaitableEvent::InitialState::NOT_SIGNALED); | 39 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 40 thread_task_runner_->PostTask( | 40 thread_task_runner_->PostTask( |
| 41 FROM_HERE, base::Bind(&WebThreadImplForWorkerScheduler::InitOnThread, | 41 FROM_HERE, |
| 42 base::Unretained(this), &completion)); | 42 base::Bind(&WebThreadImplForWorkerScheduler::InitOnThread, |
| 43 base::Unretained(this), &completion)); |
| 43 completion.Wait(); | 44 completion.Wait(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 WebThreadImplForWorkerScheduler::~WebThreadImplForWorkerScheduler() { | 47 WebThreadImplForWorkerScheduler::~WebThreadImplForWorkerScheduler() { |
| 47 if (task_runner_delegate_) { | 48 if (task_runner_delegate_) { |
| 48 base::WaitableEvent completion( | 49 base::WaitableEvent completion( |
| 49 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 50 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 50 base::WaitableEvent::InitialState::NOT_SIGNALED); | 51 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 51 // Restore the original task runner so that the thread can tear itself down. | 52 // Restore the original task runner so that the thread can tear itself down. |
| 52 thread_task_runner_->PostTask( | 53 thread_task_runner_->PostTask( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 worker_scheduler_->AddTaskObserver(observer); | 124 worker_scheduler_->AddTaskObserver(observer); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void WebThreadImplForWorkerScheduler::RemoveTaskObserverInternal( | 127 void WebThreadImplForWorkerScheduler::RemoveTaskObserverInternal( |
| 127 base::MessageLoop::TaskObserver* observer) { | 128 base::MessageLoop::TaskObserver* observer) { |
| 128 worker_scheduler_->RemoveTaskObserver(observer); | 129 worker_scheduler_->RemoveTaskObserver(observer); |
| 129 } | 130 } |
| 130 | 131 |
| 131 } // namespace scheduler | 132 } // namespace scheduler |
| 132 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |