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

Side by Side Diff: base/crypto/capi_util.cc

Issue 2828019: Add a locked version of CryptAcquireContext (Closed)
Patch Set: Forgot one reference... Created 10 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "base/crypto/capi_util.h"
6
7 #include "base/basictypes.h"
8 #include "base/lock.h"
9 #include "base/singleton.h"
10
11 namespace {
12
13 class CAPIUtilSingleton {
14 public:
15 static CAPIUtilSingleton* GetInstance() {
16 return Singleton<CAPIUtilSingleton>::get();
17 }
18
19 // Returns a lock to guard calls to CryptAcquireContext with
20 // CRYPT_DELETEKEYSET or CRYPT_NEWKEYSET.
21 Lock& acquire_context_lock() {
22 return acquire_context_lock_;
23 }
24
25 private:
26 friend class Singleton<CAPIUtilSingleton>;
27 friend struct DefaultSingletonTraits<CAPIUtilSingleton>;
28
29 CAPIUtilSingleton() {
wtc 2010/06/23 16:44:15 Nit: consider writing a method with an empty body
30 }
31
32 Lock acquire_context_lock_;
33
34 DISALLOW_COPY_AND_ASSIGN(CAPIUtilSingleton);
35 };
36
37 } // namespace
38
39 namespace base {
40
41 BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
42 const TCHAR* container,
43 const TCHAR* provider,
44 DWORD prov_type,
45 DWORD flags)
46 {
47 AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
48 return CryptAcquireContext(prov, container, provider, prov_type, flags);
49 }
50
51 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698