Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |