OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_APP_SCOPED_OLE_INITIALIZER_H_ | 5 #ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_ |
6 #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ | 6 #define CHROME_APP_SCOPED_OLE_INITIALIZER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 | 11 |
12 // Wraps OLE initialization in a cross-platform class meant to be used on the | 12 // Wraps OLE initialization in a cross-platform class meant to be used on the |
13 // stack so init/uninit is done with scoping. This class is ok for use by | 13 // stack so init/uninit is done with scoping. This class is ok for use by |
14 // non-windows platforms; it just doesn't do anything. | 14 // non-windows platforms; it just doesn't do anything. |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 | 17 |
18 #include <ole2.h> | 18 #include <ole2.h> |
19 | 19 |
20 class ScopedOleInitializer { | 20 class ScopedOleInitializer { |
21 public: | 21 public: |
22 ScopedOleInitializer() { | 22 ScopedOleInitializer() { |
23 int ole_result = OleInitialize(NULL); | 23 int ole_result = OleInitialize(NULL); |
24 DCHECK(ole_result == S_OK); | 24 DCHECK_EQ(ole_result, S_OK); |
25 } | 25 } |
26 ~ScopedOleInitializer() { | 26 ~ScopedOleInitializer() { |
27 OleUninitialize(); | 27 OleUninitialize(); |
28 } | 28 } |
29 }; | 29 }; |
30 | 30 |
31 #else | 31 #else |
32 | 32 |
33 class ScopedOleInitializer { | 33 class ScopedOleInitializer { |
34 public: | 34 public: |
35 // Empty, this class does nothing on non-win32 systems. Empty ctor is | 35 // Empty, this class does nothing on non-win32 systems. Empty ctor is |
36 // necessary to avoid "unused variable" warning on gcc. | 36 // necessary to avoid "unused variable" warning on gcc. |
37 ScopedOleInitializer() { } | 37 ScopedOleInitializer() { } |
38 }; | 38 }; |
39 | 39 |
40 #endif | 40 #endif |
41 | 41 |
42 #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_ | 42 #endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_ |
OLD | NEW |