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

Unified Diff: base/win/scoped_com_initializer.h

Issue 8275030: Support MTA as well in the scoped COM initializer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_com_initializer.h
===================================================================
--- base/win/scoped_com_initializer.h (revision 105060)
+++ base/win/scoped_com_initializer.h (working copy)
@@ -16,18 +16,29 @@
namespace base {
namespace win {
-// Initializes COM in the constructor (STA), and uninitializes COM in the
+// Initializes COM in the constructor (STA or MTA), and uninitializes COM in the
// destructor.
class ScopedCOMInitializer {
public:
+ // Enum value provided to initialize the thread as an MTA instead of STA.
+ enum SelectMTA { kMTA };
+
+ // Constructor for STA initialization.
ScopedCOMInitializer() : hr_(CoInitialize(NULL)) {
}
+ // Constructor for MTA initialization.
+ explicit ScopedCOMInitializer(SelectMTA mta)
+ : hr_(CoInitializeEx(NULL, COINIT_MULTITHREADED)) {
+ }
+
ScopedCOMInitializer::~ScopedCOMInitializer() {
if (SUCCEEDED(hr_))
CoUninitialize();
}
+ bool succeeded() const { return SUCCEEDED(hr_); }
+
private:
HRESULT hr_;
@@ -45,9 +56,13 @@
// Do-nothing class for other platforms.
class ScopedCOMInitializer {
public:
+ enum SelectMTA { kMTA };
ScopedCOMInitializer() {}
+ explicit ScopedCOMInitializer(SelectMTA mta) {}
~ScopedCOMInitializer() {}
+ bool succeeded() const { return true; }
+
private:
DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698