diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 08:20:49 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 08:20:49 +0000 |
commit | 8ff5726166f19eef46af3d2e5026607a41cca681 (patch) | |
tree | b42ea2badb57e337cf44e264356dde17290664c8 /remoting/base/auto_thread.cc | |
parent | 2d92cfe31b1bf40f0b1b9985500e4e557d710f50 (diff) | |
download | chromium_src-8ff5726166f19eef46af3d2e5026607a41cca681.zip chromium_src-8ff5726166f19eef46af3d2e5026607a41cca681.tar.gz chromium_src-8ff5726166f19eef46af3d2e5026607a41cca681.tar.bz2 |
Revert 169595 - Add AutoThread types for Windows that initialize COM.
This CL adds AutoThread types that create a UI MessageLoop on the
thread and initialize COM for single- or multi-threaded used.
BUG=145856
Review URL: https://chromiumcodereview.appspot.com/11348087
Speculative revert to fix deterministic failures in remoting_unittests
that are without log output; they were introduced by one of three
changes, and this is the only one that touches remoting.
TBR=wez@chromium.org
Review URL: https://codereview.chromium.org/11299194
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base/auto_thread.cc')
-rw-r--r-- | remoting/base/auto_thread.cc | 69 |
1 files changed, 7 insertions, 62 deletions
diff --git a/remoting/base/auto_thread.cc b/remoting/base/auto_thread.cc index 9f51378..324ccc3 100644 --- a/remoting/base/auto_thread.cc +++ b/remoting/base/auto_thread.cc @@ -12,34 +12,11 @@ #include "base/synchronization/waitable_event.h" #include "remoting/base/auto_thread_task_runner.h" -#if defined(OS_WIN) -#include "base/win/scoped_com_initializer.h" -#endif - namespace remoting { -namespace { - -#if defined(OS_WIN) -scoped_ptr<base::win::ScopedCOMInitializer> CreateComInitializer( - AutoThread::ComInitType type) { - scoped_ptr<base::win::ScopedCOMInitializer> initializer; - if (type == AutoThread::COM_INIT_MTA) { - initializer.reset(new base::win::ScopedCOMInitializer( - base::win::ScopedCOMInitializer::kMTA)); - } else if (type == AutoThread::COM_INIT_STA) { - initializer.reset(new base::win::ScopedCOMInitializer()); - } - return initializer.Pass(); -} -#endif - -} - // Used to pass data to ThreadMain. This structure is allocated on the stack // from within StartWithType. struct AutoThread::StartupData { - // Fields describing the desired thread behaviour. MessageLoop::Type loop_type; // Used to receive the AutoThreadTaskRunner for the thread. @@ -60,9 +37,12 @@ scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithType( MessageLoop::Type type) { AutoThread* thread = new AutoThread(name, joiner); scoped_refptr<AutoThreadTaskRunner> task_runner = thread->StartWithType(type); - if (!task_runner) + if (task_runner.get()) { + return task_runner; + } else { delete thread; - return task_runner; + return NULL; + } } // static @@ -71,28 +51,8 @@ scoped_refptr<AutoThreadTaskRunner> AutoThread::Create( return CreateWithType(name, joiner, MessageLoop::TYPE_DEFAULT); } -#if defined(OS_WIN) -// static -scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithLoopAndComInitTypes( - const char* name, - scoped_refptr<AutoThreadTaskRunner> joiner, - MessageLoop::Type loop_type, - ComInitType com_init_type) { - AutoThread* thread = new AutoThread(name, joiner); - thread->SetComInitType(com_init_type); - scoped_refptr<AutoThreadTaskRunner> task_runner = - thread->StartWithType(loop_type); - if (!task_runner) - delete thread; - return task_runner; -} -#endif - AutoThread::AutoThread(const char* name) : startup_data_(NULL), -#if defined(OS_WIN) - com_init_type_(COM_INIT_NONE), -#endif thread_(0), name_(name), was_quit_properly_(false) { @@ -100,9 +60,6 @@ AutoThread::AutoThread(const char* name) AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner) : startup_data_(NULL), -#if defined(OS_WIN) - com_init_type_(COM_INIT_NONE), -#endif thread_(0), name_(name), was_quit_properly_(false), @@ -121,9 +78,6 @@ AutoThread::~AutoThread() { scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType(MessageLoop::Type type) { DCHECK(!thread_); -#if defined(OS_WIN) - DCHECK(com_init_type_ != COM_INIT_STA || type == MessageLoop::TYPE_UI); -#endif StartupData startup_data(type); startup_data_ = &startup_data; @@ -149,12 +103,9 @@ AutoThread::StartWithType(MessageLoop::Type type) { return startup_data.task_runner; } -#if defined(OS_WIN) -void AutoThread::SetComInitType(ComInitType com_init_type) { - DCHECK_EQ(com_init_type_, COM_INIT_NONE); - com_init_type_ = com_init_type; +scoped_refptr<AutoThreadTaskRunner> AutoThread::Start() { + return StartWithType(MessageLoop::TYPE_DEFAULT); } -#endif void AutoThread::QuitThread( scoped_refptr<base::SingleThreadTaskRunner> task_runner) { @@ -199,12 +150,6 @@ void AutoThread::ThreadMain() { // startup_data_ can't be touched anymore since the starting thread is now // unlocked. -#if defined(OS_WIN) - // Initialize COM on the thread, if requested. - scoped_ptr<base::win::ScopedCOMInitializer> com_initializer( - CreateComInitializer(com_init_type_)); -#endif - message_loop.Run(); // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. |