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

Side by Side Diff: base/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: 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
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 BASE_SCOPED_NSS_TYPES_H_
6 #define BASE_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 base {
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 base
51
52 #endif // BASE_SCOPED_NSS_TYPES_H_
OLDNEW
« no previous file with comments | « base/crypto/scoped_capi_types.h ('k') | base/crypto/secure_hash.h » ('j') | base/nss_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698