Index: base/threading/thread.cc |
=================================================================== |
--- base/threading/thread.cc (revision 162015) |
+++ base/threading/thread.cc (working copy) |
@@ -11,6 +11,10 @@ |
#include "base/threading/thread_restrictions.h" |
#include "base/synchronization/waitable_event.h" |
+#if defined(OS_WIN) |
+#include "base/win/scoped_com_initializer.h" |
+#endif |
+ |
namespace base { |
namespace { |
@@ -60,11 +64,20 @@ |
} |
bool Thread::Start() { |
- return StartWithOptions(Options()); |
+ Options options; |
+#if defined(OS_WIN) |
+ if (com_status_ == STA) |
+ options.message_loop_type = MessageLoop::TYPE_UI; |
+#endif |
+ return StartWithOptions(options); |
} |
bool Thread::StartWithOptions(const Options& options) { |
DCHECK(!message_loop_); |
+#if defined(OS_WIN) |
+ DCHECK((com_status_ != STA) || |
+ (options.message_loop_type == MessageLoop::TYPE_UI)); |
+#endif |
SetThreadWasQuitProperly(false); |
@@ -90,7 +103,7 @@ |
} |
void Thread::Stop() { |
- if (!thread_was_started()) |
+ if (!started_) |
return; |
StopSoon(); |
@@ -157,6 +170,14 @@ |
message_loop.set_thread_name(name_); |
message_loop_ = &message_loop; |
+#if defined(OS_WIN) |
+ if (com_status_ != NONE) { |
+ com_initializer_.reset((com_status_ == STA) ? |
+ new win::ScopedCOMInitializer() : |
+ new win::ScopedCOMInitializer(win::ScopedCOMInitializer::kMTA)); |
+ } |
+#endif |
+ |
// Let the thread do extra initialization. |
// Let's do this before signaling we are started. |
Init(); |
@@ -172,6 +193,10 @@ |
// Let the thread do extra cleanup. |
CleanUp(); |
+#if defined(OS_WIN) |
+ com_initializer_.reset(); |
Ami GONE FROM CHROMIUM
2012/10/16 02:52:03
observation: this variable is only used in this fu
|
+#endif |
+ |
// Assert that MessageLoop::Quit was called by ThreadQuitHelper. |
DCHECK(GetThreadWasQuitProperly()); |