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 CRYPTO_SCOPED_CAPI_TYPES_H_ | 5 #ifndef CRYPTO_SCOPED_CAPI_TYPES_H_ |
6 #define CRYPTO_SCOPED_CAPI_TYPES_H_ | 6 #define CRYPTO_SCOPED_CAPI_TYPES_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" |
13 #include "crypto/wincrypt_shim.h" | 14 #include "crypto/wincrypt_shim.h" |
14 | 15 |
15 namespace crypto { | 16 namespace crypto { |
16 | 17 |
17 // Simple destructor for the Free family of CryptoAPI functions, such as | 18 // Simple destructor for the Free family of CryptoAPI functions, such as |
18 // CryptDestroyHash, which take only a single argument to release. | 19 // CryptDestroyHash, which take only a single argument to release. |
19 template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle)> | 20 template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle)> |
20 struct CAPIDestroyer { | 21 struct CAPIDestroyer { |
21 void operator()(CAPIHandle handle) const { | 22 void operator()(CAPIHandle handle) const { |
22 if (handle) { | 23 if (handle) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 113 |
113 typedef ScopedCAPIHandle< | 114 typedef ScopedCAPIHandle< |
114 HCRYPTKEY, CAPIDestroyer<HCRYPTKEY, CryptDestroyKey> > ScopedHCRYPTKEY; | 115 HCRYPTKEY, CAPIDestroyer<HCRYPTKEY, CryptDestroyKey> > ScopedHCRYPTKEY; |
115 | 116 |
116 typedef ScopedCAPIHandle< | 117 typedef ScopedCAPIHandle< |
117 HCRYPTHASH, CAPIDestroyer<HCRYPTHASH, CryptDestroyHash> > ScopedHCRYPTHASH; | 118 HCRYPTHASH, CAPIDestroyer<HCRYPTHASH, CryptDestroyHash> > ScopedHCRYPTHASH; |
118 | 119 |
119 } // namespace crypto | 120 } // namespace crypto |
120 | 121 |
121 #endif // CRYPTO_SCOPED_CAPI_TYPES_H_ | 122 #endif // CRYPTO_SCOPED_CAPI_TYPES_H_ |
OLD | NEW |