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