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