Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / crypto / capi_util.cc
blob2cf10625ec34fc09f66a0b8964c478e9cd50e5ea
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.
5 #include "crypto/capi_util.h"
7 #include "base/basictypes.h"
8 #include "base/memory/singleton.h"
9 #include "base/synchronization/lock.h"
11 namespace {
13 class CAPIUtilSingleton {
14 public:
15 static CAPIUtilSingleton* GetInstance() {
16 return Singleton<CAPIUtilSingleton>::get();
19 // Returns a lock to guard calls to CryptAcquireContext with
20 // CRYPT_DELETEKEYSET or CRYPT_NEWKEYSET.
21 base::Lock& acquire_context_lock() {
22 return acquire_context_lock_;
25 private:
26 friend class Singleton<CAPIUtilSingleton>;
27 friend struct DefaultSingletonTraits<CAPIUtilSingleton>;
29 CAPIUtilSingleton() {}
31 base::Lock acquire_context_lock_;
33 DISALLOW_COPY_AND_ASSIGN(CAPIUtilSingleton);
36 } // namespace
38 namespace crypto {
40 BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
41 LPCWSTR container,
42 LPCWSTR provider,
43 DWORD prov_type,
44 DWORD flags) {
45 base::AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
46 return CryptAcquireContext(prov, container, provider, prov_type, flags);
49 void* WINAPI CryptAlloc(size_t size) {
50 return malloc(size);
53 void WINAPI CryptFree(void* p) {
54 free(p);
57 } // namespace crypto