blob: af66918f3cae106ed89a411dedcf7b518134d692 [file] [log] [blame]
[email protected]4156b9a42011-03-10 23:36:161// 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
[email protected]4b559b4d2011-04-14 17:37:145#include "crypto/mac_security_services_lock.h"
[email protected]4156b9a42011-03-10 23:36:166
[email protected]3b63f8f42011-03-28 01:54:157#include "base/memory/singleton.h"
[email protected]4156b9a42011-03-10 23:36:168#include "base/synchronization/lock.h"
9
10namespace {
11
12// This singleton pertains to Apple's wrappers over their own CSSM handles,
13// as opposed to our own CSSM_CSP_HANDLE in cssm_init.cc.
14class SecurityServicesSingleton {
15 public:
16 static SecurityServicesSingleton* GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2217 return base::Singleton<
18 SecurityServicesSingleton,
19 base::LeakySingletonTraits<SecurityServicesSingleton>>::get();
[email protected]4156b9a42011-03-10 23:36:1620 }
21
22 base::Lock& lock() { return lock_; }
23
24 private:
olli.raula36aa8be2015-09-10 11:14:2225 friend struct base::DefaultSingletonTraits<SecurityServicesSingleton>;
[email protected]4156b9a42011-03-10 23:36:1626
27 SecurityServicesSingleton() {}
28 ~SecurityServicesSingleton() {}
29
30 base::Lock lock_;
31
32 DISALLOW_COPY_AND_ASSIGN(SecurityServicesSingleton);
33};
34
35} // namespace
36
[email protected]4b559b4d2011-04-14 17:37:1437namespace crypto {
[email protected]4156b9a42011-03-10 23:36:1638
39base::Lock& GetMacSecurityServicesLock() {
40 return SecurityServicesSingleton::GetInstance()->lock();
41}
42
[email protected]4b559b4d2011-04-14 17:37:1443} // namespace crypto