| 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" |
| 11 #include "base/threading/thread_local.h" | 11 #include "base/threading/thread_local.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "remoting/base/auto_thread_task_runner.h" | 14 #include "remoting/base/auto_thread_task_runner.h" |
| 15 | 15 |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include "base/win/scoped_com_initializer.h" | 17 #include "base/win/scoped_com_initializer.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 25 scoped_ptr<base::win::ScopedCOMInitializer> CreateComInitializer( | 25 std::unique_ptr<base::win::ScopedCOMInitializer> CreateComInitializer( |
| 26 AutoThread::ComInitType type) { | 26 AutoThread::ComInitType type) { |
| 27 scoped_ptr<base::win::ScopedCOMInitializer> initializer; | 27 std::unique_ptr<base::win::ScopedCOMInitializer> initializer; |
| 28 if (type == AutoThread::COM_INIT_MTA) { | 28 if (type == AutoThread::COM_INIT_MTA) { |
| 29 initializer.reset(new base::win::ScopedCOMInitializer( | 29 initializer.reset(new base::win::ScopedCOMInitializer( |
| 30 base::win::ScopedCOMInitializer::kMTA)); | 30 base::win::ScopedCOMInitializer::kMTA)); |
| 31 } else if (type == AutoThread::COM_INIT_STA) { | 31 } else if (type == AutoThread::COM_INIT_STA) { |
| 32 initializer.reset(new base::win::ScopedCOMInitializer()); | 32 initializer.reset(new base::win::ScopedCOMInitializer()); |
| 33 } | 33 } |
| 34 return initializer; | 34 return initializer; |
| 35 } | 35 } |
| 36 #endif | 36 #endif |
| 37 | 37 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 base::Bind(&AutoThread::QuitThread, | 195 base::Bind(&AutoThread::QuitThread, |
| 196 base::Unretained(this), | 196 base::Unretained(this), |
| 197 message_loop.task_runner())); | 197 message_loop.task_runner())); |
| 198 | 198 |
| 199 startup_data_->event.Signal(); | 199 startup_data_->event.Signal(); |
| 200 // startup_data_ can't be touched anymore since the starting thread is now | 200 // startup_data_ can't be touched anymore since the starting thread is now |
| 201 // unlocked. | 201 // unlocked. |
| 202 | 202 |
| 203 #if defined(OS_WIN) | 203 #if defined(OS_WIN) |
| 204 // Initialize COM on the thread, if requested. | 204 // Initialize COM on the thread, if requested. |
| 205 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer( | 205 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer( |
| 206 CreateComInitializer(com_init_type_)); | 206 CreateComInitializer(com_init_type_)); |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 message_loop.Run(); | 209 message_loop.Run(); |
| 210 | 210 |
| 211 // Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread. | 211 // Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread. |
| 212 DCHECK(was_quit_properly_); | 212 DCHECK(was_quit_properly_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace base | 215 } // namespace base |
| OLD | NEW |