Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2959)

Unified Diff: base/threading/com_thread_win.cc

Issue 11048029: Allow Thread to initialize COM for Windows consumers who need it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/com_thread.h ('k') | base/threading/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/com_thread_win.cc
===================================================================
--- base/threading/com_thread_win.cc (revision 0)
+++ base/threading/com_thread_win.cc (working copy)
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/threading/com_thread.h"
+
+namespace base {
+
+ComThread::ComThread(const char* name, bool use_mta)
+ : Thread(name),
+ use_mta_(use_mta) {
+}
+
+ComThread::~ComThread() {
+ Stop();
+}
+
+bool ComThread::Start() {
+ if (!use_mta_)
Jamie 2012/10/03 23:46:04 Is this test correct? It's doing the opposite to w
Peter Kasting 2012/10/03 23:47:12 No, it's wrong. Sigh. Thanks :(
+ return Thread::Start();
+
+ // STA COM objects require a UI message loop in order to pump Windows
+ // messages, which they may use for various purposes.
+ Thread::Options thread_options(MessageLoop::TYPE_UI, 0);
+ return StartWithOptions(thread_options);
+}
+
+void ComThread::Init() {
+ com_initializer_.reset(use_mta_ ?
+ new win::ScopedCOMInitializer(win::ScopedCOMInitializer::kMTA) :
+ new win::ScopedCOMInitializer());
+}
+
+void ComThread::CleanUp() {
+ com_initializer_.reset();
+}
+
+} // namespace base
Property changes on: base/threading/com_thread_win.cc
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
« no previous file with comments | « base/threading/com_thread.h ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698