| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_WIN_SCOPED_COM_INITIALIZER_H_ | 5 #ifndef BASE_WIN_SCOPED_COM_INITIALIZER_H_ |
| 6 #define BASE_WIN_SCOPED_COM_INITIALIZER_H_ | 6 #define BASE_WIN_SCOPED_COM_INITIALIZER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool succeeded() const { return SUCCEEDED(hr_); } | 45 bool succeeded() const { return SUCCEEDED(hr_); } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 void Initialize(COINIT init) { | 48 void Initialize(COINIT init) { |
| 49 #ifndef NDEBUG | 49 #ifndef NDEBUG |
| 50 thread_id_ = GetCurrentThreadId(); | 50 thread_id_ = GetCurrentThreadId(); |
| 51 #endif | 51 #endif |
| 52 hr_ = CoInitializeEx(NULL, init); | 52 hr_ = CoInitializeEx(NULL, init); |
| 53 #ifndef NDEBUG |
| 54 switch (hr_) { |
| 55 case S_FALSE: |
| 56 LOG(ERROR) << "Multiple CoInitialize() called for thread " |
| 57 << thread_id_; |
| 58 break; |
| 59 case RPC_E_CHANGED_MODE: |
| 60 DCHECK(false) << "Invalid COM thread model change"; |
| 61 break; |
| 62 default: |
| 63 break; |
| 64 } |
| 65 #endif |
| 53 } | 66 } |
| 54 | 67 |
| 55 HRESULT hr_; | 68 HRESULT hr_; |
| 56 #ifndef NDEBUG | 69 #ifndef NDEBUG |
| 57 // In debug builds we use this variable to catch a potential bug where a | 70 // In debug builds we use this variable to catch a potential bug where a |
| 58 // ScopedCOMInitializer instance is deleted on a different thread than it | 71 // ScopedCOMInitializer instance is deleted on a different thread than it |
| 59 // was initially created on. If that ever happens it can have bad | 72 // was initially created on. If that ever happens it can have bad |
| 60 // consequences and the cause can be tricky to track down. | 73 // consequences and the cause can be tricky to track down. |
| 61 DWORD thread_id_; | 74 DWORD thread_id_; |
| 62 #endif | 75 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 private: | 98 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); | 99 DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); |
| 87 }; | 100 }; |
| 88 | 101 |
| 89 } // namespace win | 102 } // namespace win |
| 90 } // namespace base | 103 } // namespace base |
| 91 | 104 |
| 92 #endif | 105 #endif |
| 93 | 106 |
| 94 #endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_ | 107 #endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_ |
| OLD | NEW |