OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/threading/com_thread.h" |
| 6 |
| 7 namespace base { |
| 8 |
| 9 ComThread::ComThread(const char* name, bool use_mta) |
| 10 : Thread(name), |
| 11 use_mta_(use_mta) { |
| 12 } |
| 13 |
| 14 ComThread::~ComThread() { |
| 15 Stop(); |
| 16 } |
| 17 |
| 18 bool ComThread::Start() { |
| 19 if (!use_mta_) |
| 20 return Thread::Start(); |
| 21 |
| 22 // STA COM objects require a UI message loop in order to pump Windows |
| 23 // messages, which they may use for various purposes. |
| 24 Thread::Options thread_options(MessageLoop::TYPE_UI, 0); |
| 25 return StartWithOptions(thread_options); |
| 26 } |
| 27 |
| 28 void ComThread::Init() { |
| 29 com_initializer_.reset(use_mta_ ? |
| 30 new win::ScopedCOMInitializer(win::ScopedCOMInitializer::kMTA) : |
| 31 new win::ScopedCOMInitializer()); |
| 32 } |
| 33 |
| 34 void ComThread::CleanUp() { |
| 35 com_initializer_.reset(); |
| 36 } |
| 37 |
| 38 } // namespace base |
OLD | NEW |