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_SCOPED_NSS_TYPES_H_ | 5 #ifndef BASE_SCOPED_NSS_TYPES_H_ |
6 #define BASE_SCOPED_NSS_TYPES_H_ | 6 #define BASE_SCOPED_NSS_TYPES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <nss.h> | 9 #include <nss.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 | 13 |
14 namespace base { | 14 namespace crypto { |
15 | 15 |
16 template <typename Type, void (*Destroyer)(Type*)> | 16 template <typename Type, void (*Destroyer)(Type*)> |
17 struct NSSDestroyer { | 17 struct NSSDestroyer { |
18 void operator()(Type* ptr) const { | 18 void operator()(Type* ptr) const { |
19 if (ptr) | 19 if (ptr) |
20 Destroyer(ptr); | 20 Destroyer(ptr); |
21 } | 21 } |
22 }; | 22 }; |
23 | 23 |
24 template <typename Type, void (*Destroyer)(Type*, PRBool), PRBool freeit> | 24 template <typename Type, void (*Destroyer)(Type*, PRBool), PRBool freeit> |
(...skipping 15 matching lines...) Expand all Loading... |
40 PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedPK11SymKey; | 40 PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedPK11SymKey; |
41 typedef scoped_ptr_malloc< | 41 typedef scoped_ptr_malloc< |
42 SECAlgorithmID, NSSDestroyer1<SECAlgorithmID, | 42 SECAlgorithmID, NSSDestroyer1<SECAlgorithmID, |
43 SECOID_DestroyAlgorithmID, | 43 SECOID_DestroyAlgorithmID, |
44 PR_TRUE> > ScopedSECAlgorithmID; | 44 PR_TRUE> > ScopedSECAlgorithmID; |
45 typedef scoped_ptr_malloc< | 45 typedef scoped_ptr_malloc< |
46 SECItem, NSSDestroyer1<SECItem, | 46 SECItem, NSSDestroyer1<SECItem, |
47 SECITEM_FreeItem, | 47 SECITEM_FreeItem, |
48 PR_TRUE> > ScopedSECItem; | 48 PR_TRUE> > ScopedSECItem; |
49 | 49 |
50 } // namespace base | 50 } // namespace crypto |
51 | 51 |
52 #endif // BASE_SCOPED_NSS_TYPES_H_ | 52 #endif // BASE_SCOPED_NSS_TYPES_H_ |
OLD | NEW |