OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/base/auto_thread.h" | 5 #include "remoting/base/auto_thread.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 delete this; | 181 delete this; |
182 } | 182 } |
183 | 183 |
184 void AutoThread::ThreadMain() { | 184 void AutoThread::ThreadMain() { |
185 // The message loop for this thread. | 185 // The message loop for this thread. |
186 base::MessageLoop message_loop(startup_data_->loop_type); | 186 base::MessageLoop message_loop(startup_data_->loop_type); |
187 | 187 |
188 // Complete the initialization of our AutoThread object. | 188 // Complete the initialization of our AutoThread object. |
189 base::PlatformThread::SetName(name_); | 189 base::PlatformThread::SetName(name_); |
190 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 190 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
191 message_loop.set_thread_name(name_); | |
192 | 191 |
193 // Return an AutoThreadTaskRunner that will cleanly quit this thread when | 192 // Return an AutoThreadTaskRunner that will cleanly quit this thread when |
194 // no more references to it remain. | 193 // no more references to it remain. |
195 startup_data_->task_runner = | 194 startup_data_->task_runner = |
196 new AutoThreadTaskRunner(message_loop.task_runner(), | 195 new AutoThreadTaskRunner(message_loop.task_runner(), |
197 base::Bind(&AutoThread::QuitThread, | 196 base::Bind(&AutoThread::QuitThread, |
198 base::Unretained(this), | 197 base::Unretained(this), |
199 message_loop.task_runner())); | 198 message_loop.task_runner())); |
200 | 199 |
201 startup_data_->event.Signal(); | 200 startup_data_->event.Signal(); |
202 // startup_data_ can't be touched anymore since the starting thread is now | 201 // startup_data_ can't be touched anymore since the starting thread is now |
203 // unlocked. | 202 // unlocked. |
204 | 203 |
205 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
206 // Initialize COM on the thread, if requested. | 205 // Initialize COM on the thread, if requested. |
207 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer( | 206 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer( |
208 CreateComInitializer(com_init_type_)); | 207 CreateComInitializer(com_init_type_)); |
209 #endif | 208 #endif |
210 | 209 |
211 message_loop.Run(); | 210 message_loop.Run(); |
212 | 211 |
213 // Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread. | 212 // Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread. |
214 DCHECK(was_quit_properly_); | 213 DCHECK(was_quit_properly_); |
215 } | 214 } |
216 | 215 |
217 } // namespace base | 216 } // namespace base |
OLD | NEW |