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