[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 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. | ||||
4 | |||||
[email protected] | 4b559b4d | 2011-04-14 17:37:14 | [diff] [blame] | 5 | #include "crypto/mac_security_services_lock.h" |
[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 6 | |
avi | dd373b8b | 2015-12-21 21:34:43 | [diff] [blame^] | 7 | #include "base/macros.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 8 | #include "base/memory/singleton.h" |
[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 9 | #include "base/synchronization/lock.h" |
10 | |||||
11 | namespace { | ||||
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. | ||||
15 | class SecurityServicesSingleton { | ||||
16 | public: | ||||
17 | static SecurityServicesSingleton* GetInstance() { | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 18 | return base::Singleton< |
19 | SecurityServicesSingleton, | ||||
20 | base::LeakySingletonTraits<SecurityServicesSingleton>>::get(); | ||||
[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 21 | } |
22 | |||||
23 | base::Lock& lock() { return lock_; } | ||||
24 | |||||
25 | private: | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 26 | friend struct base::DefaultSingletonTraits<SecurityServicesSingleton>; |
[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 27 | |
28 | SecurityServicesSingleton() {} | ||||
29 | ~SecurityServicesSingleton() {} | ||||
30 | |||||
31 | base::Lock lock_; | ||||
32 | |||||
33 | DISALLOW_COPY_AND_ASSIGN(SecurityServicesSingleton); | ||||
34 | }; | ||||
35 | |||||
36 | } // namespace | ||||
37 | |||||
[email protected] | 4b559b4d | 2011-04-14 17:37:14 | [diff] [blame] | 38 | namespace crypto { |
[email protected] | 4156b9a4 | 2011-03-10 23:36:16 | [diff] [blame] | 39 | |
40 | base::Lock& GetMacSecurityServicesLock() { | ||||
41 | return SecurityServicesSingleton::GetInstance()->lock(); | ||||
42 | } | ||||
43 | |||||
[email protected] | 4b559b4d | 2011-04-14 17:37:14 | [diff] [blame] | 44 | } // namespace crypto |