| 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 CRYPTO_SCOPED_NSS_TYPES_H_ | 5 #ifndef CRYPTO_SCOPED_NSS_TYPES_H_ |
| 6 #define CRYPTO_SCOPED_NSS_TYPES_H_ | 6 #define CRYPTO_SCOPED_NSS_TYPES_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <keyhi.h> |
| 9 #include <nss.h> | 10 #include <nss.h> |
| 10 #include <pk11pub.h> | 11 #include <pk11pub.h> |
| 11 | 12 |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 | 14 |
| 14 namespace crypto { | 15 namespace crypto { |
| 15 | 16 |
| 16 template <typename Type, void (*Destroyer)(Type*)> | 17 template <typename Type, void (*Destroyer)(Type*)> |
| 17 struct NSSDestroyer { | 18 struct NSSDestroyer { |
| 18 void operator()(Type* ptr) const { | 19 void operator()(Type* ptr) const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 // Define some convenient scopers around NSS pointers. | 33 // Define some convenient scopers around NSS pointers. |
| 33 typedef scoped_ptr_malloc< | 34 typedef scoped_ptr_malloc< |
| 34 PK11Context, NSSDestroyer1<PK11Context, | 35 PK11Context, NSSDestroyer1<PK11Context, |
| 35 PK11_DestroyContext, | 36 PK11_DestroyContext, |
| 36 PR_TRUE> > ScopedPK11Context; | 37 PR_TRUE> > ScopedPK11Context; |
| 37 typedef scoped_ptr_malloc< | 38 typedef scoped_ptr_malloc< |
| 38 PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot> > ScopedPK11Slot; | 39 PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot> > ScopedPK11Slot; |
| 39 typedef scoped_ptr_malloc< | 40 typedef scoped_ptr_malloc< |
| 40 PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedPK11SymKey; | 41 PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedPK11SymKey; |
| 41 typedef scoped_ptr_malloc< | 42 typedef scoped_ptr_malloc< |
| 43 SECKEYPublicKey, NSSDestroyer<SECKEYPublicKey, SECKEY_DestroyPublicKey> > |
| 44 ScopedSECKEYPublicKey; |
| 45 typedef scoped_ptr_malloc< |
| 46 SECKEYPrivateKey, NSSDestroyer<SECKEYPrivateKey, SECKEY_DestroyPrivateKey> > |
| 47 ScopedSECKEYPrivateKey; |
| 48 typedef scoped_ptr_malloc< |
| 42 SECAlgorithmID, NSSDestroyer1<SECAlgorithmID, | 49 SECAlgorithmID, NSSDestroyer1<SECAlgorithmID, |
| 43 SECOID_DestroyAlgorithmID, | 50 SECOID_DestroyAlgorithmID, |
| 44 PR_TRUE> > ScopedSECAlgorithmID; | 51 PR_TRUE> > ScopedSECAlgorithmID; |
| 45 typedef scoped_ptr_malloc< | 52 typedef scoped_ptr_malloc< |
| 46 SECItem, NSSDestroyer1<SECItem, | 53 SECItem, NSSDestroyer1<SECItem, |
| 47 SECITEM_FreeItem, | 54 SECITEM_FreeItem, |
| 48 PR_TRUE> > ScopedSECItem; | 55 PR_TRUE> > ScopedSECItem; |
| 49 | 56 |
| 50 } // namespace crypto | 57 } // namespace crypto |
| 51 | 58 |
| 52 #endif // CRYPTO_SCOPED_NSS_TYPES_H_ | 59 #endif // CRYPTO_SCOPED_NSS_TYPES_H_ |
| OLD | NEW |