diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-01 20:51:37 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-01 20:51:37 +0000 |
commit | 5f7e4518c9cec62df4ed1c34daf003382b05ec70 (patch) | |
tree | 039579d56e67f6272d1f52c788e4324cd499a83b /base/win | |
parent | f14b1320428ad7935b70b677525021c1cf628afa (diff) | |
download | chromium_src-5f7e4518c9cec62df4ed1c34daf003382b05ec70.zip chromium_src-5f7e4518c9cec62df4ed1c34daf003382b05ec70.tar.gz chromium_src-5f7e4518c9cec62df4ed1c34daf003382b05ec70.tar.bz2 |
Clean up scoped_com_initializer.h, primarily by removing #ifdefs for non-Windows. Instead change files that use this to specifically #ifdef it for OS_WIN, like we do most other Windows-specific code.
I plan to factor out the "subclass base::Thread to init MTA on Windows" pattern to its own file in a followup change.
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/10990079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r-- | base/win/scoped_com_initializer.h | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/base/win/scoped_com_initializer.h b/base/win/scoped_com_initializer.h index 48388fa..392c351 100644 --- a/base/win/scoped_com_initializer.h +++ b/base/win/scoped_com_initializer.h @@ -5,14 +5,12 @@ #ifndef BASE_WIN_SCOPED_COM_INITIALIZER_H_ #define BASE_WIN_SCOPED_COM_INITIALIZER_H_ +#include <objbase.h> + #include "base/basictypes.h" #include "base/logging.h" #include "build/build_config.h" -#if defined(OS_WIN) - -#include <objbase.h> - namespace base { namespace win { @@ -38,7 +36,7 @@ class ScopedCOMInitializer { // Using the windows API directly to avoid dependency on platform_thread. DCHECK_EQ(GetCurrentThreadId(), thread_id_); #endif - if (SUCCEEDED(hr_)) + if (succeeded()) CoUninitialize(); } @@ -51,17 +49,10 @@ class ScopedCOMInitializer { #endif hr_ = CoInitializeEx(NULL, init); #ifndef NDEBUG - switch (hr_) { - case S_FALSE: - LOG(ERROR) << "Multiple CoInitialize() called for thread " - << thread_id_; - break; - case RPC_E_CHANGED_MODE: - DCHECK(false) << "Invalid COM thread model change"; - break; - default: - break; - } + if (hr_ == S_FALSE) + LOG(ERROR) << "Multiple CoInitialize() calls for thread " << thread_id_; + else + DCHECK_NE(RPC_E_CHANGED_MODE, hr_) << "Invalid COM thread model change"; #endif } @@ -80,28 +71,4 @@ class ScopedCOMInitializer { } // namespace win } // namespace base -#else - -namespace base { -namespace win { - -// 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); -}; - -} // namespace win -} // namespace base - -#endif - #endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_ |