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

Side by Side Diff: components/scheduler/child/webthread_impl_for_worker_scheduler.cc

Issue 2028193002: Migrate WaitableEvent to enum-based constructor in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: rm comment explaining true/false Created 4 years, 6 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
OLDNEW
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/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 15 matching lines...) Expand all
26 WebThreadImplForWorkerScheduler::WebThreadImplForWorkerScheduler( 26 WebThreadImplForWorkerScheduler::WebThreadImplForWorkerScheduler(
27 const char* name, 27 const char* name,
28 base::Thread::Options options) 28 base::Thread::Options options)
29 : thread_(new base::Thread(name ? name : std::string())) { 29 : thread_(new base::Thread(name ? name : std::string())) {
30 bool started = thread_->StartWithOptions(options); 30 bool started = thread_->StartWithOptions(options);
31 CHECK(started); 31 CHECK(started);
32 thread_task_runner_ = thread_->task_runner(); 32 thread_task_runner_ = thread_->task_runner();
33 } 33 }
34 34
35 void WebThreadImplForWorkerScheduler::Init() { 35 void WebThreadImplForWorkerScheduler::Init() {
36 base::WaitableEvent completion(false, false); 36 base::WaitableEvent completion(
37 base::WaitableEvent::ResetPolicy::AUTOMATIC,
38 base::WaitableEvent::InitialState::NOT_SIGNALED);
37 thread_task_runner_->PostTask( 39 thread_task_runner_->PostTask(
38 FROM_HERE, base::Bind(&WebThreadImplForWorkerScheduler::InitOnThread, 40 FROM_HERE, base::Bind(&WebThreadImplForWorkerScheduler::InitOnThread,
39 base::Unretained(this), &completion)); 41 base::Unretained(this), &completion));
40 completion.Wait(); 42 completion.Wait();
41 } 43 }
42 44
43 WebThreadImplForWorkerScheduler::~WebThreadImplForWorkerScheduler() { 45 WebThreadImplForWorkerScheduler::~WebThreadImplForWorkerScheduler() {
44 if (task_runner_delegate_) { 46 if (task_runner_delegate_) {
45 base::WaitableEvent completion(false, false); 47 base::WaitableEvent completion(
48 base::WaitableEvent::ResetPolicy::AUTOMATIC,
49 base::WaitableEvent::InitialState::NOT_SIGNALED);
46 // Restore the original task runner so that the thread can tear itself down. 50 // Restore the original task runner so that the thread can tear itself down.
47 thread_task_runner_->PostTask( 51 thread_task_runner_->PostTask(
48 FROM_HERE, 52 FROM_HERE,
49 base::Bind(&WebThreadImplForWorkerScheduler::RestoreTaskRunnerOnThread, 53 base::Bind(&WebThreadImplForWorkerScheduler::RestoreTaskRunnerOnThread,
50 base::Unretained(this), &completion)); 54 base::Unretained(this), &completion));
51 completion.Wait(); 55 completion.Wait();
52 } 56 }
53 thread_->Stop(); 57 thread_->Stop();
54 } 58 }
55 59
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 base::MessageLoop::TaskObserver* observer) { 120 base::MessageLoop::TaskObserver* observer) {
117 worker_scheduler_->AddTaskObserver(observer); 121 worker_scheduler_->AddTaskObserver(observer);
118 } 122 }
119 123
120 void WebThreadImplForWorkerScheduler::RemoveTaskObserverInternal( 124 void WebThreadImplForWorkerScheduler::RemoveTaskObserverInternal(
121 base::MessageLoop::TaskObserver* observer) { 125 base::MessageLoop::TaskObserver* observer) {
122 worker_scheduler_->RemoveTaskObserver(observer); 126 worker_scheduler_->RemoveTaskObserver(observer);
123 } 127 }
124 128
125 } // namespace scheduler 129 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/prefs/pref_member_unittest.cc ('k') | components/scheduler/child/webthread_impl_for_worker_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698