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

Unified Diff: base/threading/thread.h

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 | « no previous file | base/threading/thread.cc » ('j') | base/threading/thread.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread.h
===================================================================
--- base/threading/thread.h (revision 162015)
+++ base/threading/thread.h (working copy)
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_THREAD_H_
-#define BASE_THREAD_H_
+#ifndef BASE_THREADING_THREAD_H_
+#define BASE_THREADING_THREAD_H_
#include <string>
@@ -12,8 +12,18 @@
#include "base/message_loop_proxy.h"
#include "base/threading/platform_thread.h"
+#if defined(OS_WIN)
+#include "base/memory/scoped_ptr.h"
+#endif
+
namespace base {
+#if defined(OS_WIN)
+namespace win {
+class ScopedCOMInitializer;
+}
+#endif
+
// A simple thread abstraction that establishes a MessageLoop on a new thread.
// The consumer uses the MessageLoop of the thread to cause code to execute on
// the thread. When this object is destroyed the thread is terminated. All
@@ -57,6 +67,18 @@
// before it is destructed.
virtual ~Thread();
+#if defined(OS_WIN)
+ // Causes the thread to initialize COM. This must be called before calling
+ // Start() or StartWithOptions(). If |use_mta| is false, the thread is also
+ // started with a TYPE_UI message loop. It is an error to call
+ // init_com_with_mta(false) and then StartWithOptions() with any message loop
+ // type other than TYPE_UI.
+ void init_com_with_mta(bool use_mta) {
+ DCHECK(!started_);
+ com_status_ = use_mta ? MTA : STA;
+ }
+#endif
+
// Starts the thread. Returns true if the thread was successfully started;
// otherwise, returns false. Upon successful return, the message_loop()
// getter will return non-null.
@@ -148,7 +170,15 @@
}
private:
- bool thread_was_started() const { return started_; }
+#if defined(OS_WIN)
+ enum ComStatus {
+ NONE,
+ STA,
+ MTA,
+ };
+ ComStatus com_status_;
+ scoped_ptr<win::ScopedCOMInitializer> com_initializer_;
+#endif
// PlatformThread::Delegate methods:
virtual void ThreadMain() OVERRIDE;
@@ -187,4 +217,4 @@
} // namespace base
-#endif // BASE_THREAD_H_
+#endif // BASE_THREADING_THREAD_H_
« no previous file with comments | « no previous file | base/threading/thread.cc » ('j') | base/threading/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698