OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Constructor for STA initialization. | 27 // Constructor for STA initialization. |
28 ScopedCOMInitializer() { | 28 ScopedCOMInitializer() { |
29 Initialize(COINIT_APARTMENTTHREADED); | 29 Initialize(COINIT_APARTMENTTHREADED); |
30 } | 30 } |
31 | 31 |
32 // Constructor for MTA initialization. | 32 // Constructor for MTA initialization. |
33 explicit ScopedCOMInitializer(SelectMTA mta) { | 33 explicit ScopedCOMInitializer(SelectMTA mta) { |
34 Initialize(COINIT_MULTITHREADED); | 34 Initialize(COINIT_MULTITHREADED); |
35 } | 35 } |
36 | 36 |
37 ScopedCOMInitializer::~ScopedCOMInitializer() { | 37 ~ScopedCOMInitializer() { |
38 #ifndef NDEBUG | 38 #ifndef NDEBUG |
39 // Using the windows API directly to avoid dependency on platform_thread. | 39 // Using the windows API directly to avoid dependency on platform_thread. |
40 DCHECK_EQ(GetCurrentThreadId(), thread_id_); | 40 DCHECK_EQ(GetCurrentThreadId(), thread_id_); |
41 #endif | 41 #endif |
42 if (SUCCEEDED(hr_)) | 42 if (SUCCEEDED(hr_)) |
43 CoUninitialize(); | 43 CoUninitialize(); |
44 } | 44 } |
45 | 45 |
46 bool succeeded() const { return SUCCEEDED(hr_); } | 46 bool succeeded() const { return SUCCEEDED(hr_); } |
47 | 47 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 private: | 86 private: |
87 DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); | 87 DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); |
88 }; | 88 }; |
89 | 89 |
90 } // namespace win | 90 } // namespace win |
91 } // namespace base | 91 } // namespace base |
92 | 92 |
93 #endif | 93 #endif |
94 | 94 |
95 #endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_ | 95 #endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_ |
OLD | NEW |