Output data about media requests to the netlog too.
[chromium-blink-merge.git] / base / crypto / capi_util.cc
blob0499492862231424835b5163f3271a7930fb76c7
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.
5 #include "base/crypto/capi_util.h"
7 #include "base/basictypes.h"
8 #include "base/lock.h"
9 #include "base/singleton.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 Lock& acquire_context_lock() {
22 return acquire_context_lock_;
25 private:
26 friend class Singleton<CAPIUtilSingleton>;
27 friend struct DefaultSingletonTraits<CAPIUtilSingleton>;
29 CAPIUtilSingleton() {}
31 Lock acquire_context_lock_;
33 DISALLOW_COPY_AND_ASSIGN(CAPIUtilSingleton);
36 } // namespace
38 namespace base {
40 BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
41 const TCHAR* container,
42 const TCHAR* provider,
43 DWORD prov_type,
44 DWORD flags)
46 AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
47 return CryptAcquireContext(prov, container, provider, prov_type, flags);
50 } // namespace base