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