Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: crypto/scoped_nss_types.h

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « crypto/scoped_capi_types.h ('k') | crypto/secure_hash.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CRYPTO_SCOPED_NSS_TYPES_H_
6 #define CRYPTO_SCOPED_NSS_TYPES_H_
7 #pragma once
8
9 #include <nss.h>
10 #include <pk11pub.h>
11
12 #include "base/memory/scoped_ptr.h"
13
14 namespace crypto {
15
16 template <typename Type, void (*Destroyer)(Type*)>
17 struct NSSDestroyer {
18 void operator()(Type* ptr) const {
19 if (ptr)
20 Destroyer(ptr);
21 }
22 };
23
24 template <typename Type, void (*Destroyer)(Type*, PRBool), PRBool freeit>
25 struct NSSDestroyer1 {
26 void operator()(Type* ptr) const {
27 if (ptr)
28 Destroyer(ptr, freeit);
29 }
30 };
31
32 // Define some convenient scopers around NSS pointers.
33 typedef scoped_ptr_malloc<
34 PK11Context, NSSDestroyer1<PK11Context,
35 PK11_DestroyContext,
36 PR_TRUE> > ScopedPK11Context;
37 typedef scoped_ptr_malloc<
38 PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot> > ScopedPK11Slot;
39 typedef scoped_ptr_malloc<
40 PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedPK11SymKey;
41 typedef scoped_ptr_malloc<
42 SECAlgorithmID, NSSDestroyer1<SECAlgorithmID,
43 SECOID_DestroyAlgorithmID,
44 PR_TRUE> > ScopedSECAlgorithmID;
45 typedef scoped_ptr_malloc<
46 SECItem, NSSDestroyer1<SECItem,
47 SECITEM_FreeItem,
48 PR_TRUE> > ScopedSECItem;
49
50 } // namespace crypto
51
52 #endif // CRYPTO_SCOPED_NSS_TYPES_H_
OLDNEW
« no previous file with comments | « crypto/scoped_capi_types.h ('k') | crypto/secure_hash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698