blob: 902a871ffdfc2c2673dba9d5857a4a808acc39d9 [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
avidd373b8b2015-12-21 21:34:437#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:158#include "base/memory/singleton.h"
[email protected]4156b9a42011-03-10 23:36:169#include "base/synchronization/lock.h"
10
11namespace {
12
13// This singleton pertains to Apple's wrappers over their own CSSM handles,
14// as opposed to our own CSSM_CSP_HANDLE in cssm_init.cc.
15class SecurityServicesSingleton {
16 public:
17 static SecurityServicesSingleton* GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2218 return base::Singleton<
19 SecurityServicesSingleton,
20 base::LeakySingletonTraits<SecurityServicesSingleton>>::get();
[email protected]4156b9a42011-03-10 23:36:1621 }
22
23 base::Lock& lock() { return lock_; }
24
25 private:
olli.raula36aa8be2015-09-10 11:14:2226 friend struct base::DefaultSingletonTraits<SecurityServicesSingleton>;
[email protected]4156b9a42011-03-10 23:36:1627
28 SecurityServicesSingleton() {}
29 ~SecurityServicesSingleton() {}
30
31 base::Lock lock_;
32
33 DISALLOW_COPY_AND_ASSIGN(SecurityServicesSingleton);
34};
35
36} // namespace
37
[email protected]4b559b4d2011-04-14 17:37:1438namespace crypto {
[email protected]4156b9a42011-03-10 23:36:1639
40base::Lock& GetMacSecurityServicesLock() {
41 return SecurityServicesSingleton::GetInstance()->lock();
42}
43
[email protected]4b559b4d2011-04-14 17:37:1444} // namespace crypto