| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "crypto/cssm_init.h" | 5 #include "crypto/cssm_init.h" |
| 6 | 6 |
| 7 #include <Security/SecBase.h> | 7 #include <Security/SecBase.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 return realloc(ptr, size); | 32 return realloc(ptr, size); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void* CSSMCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) { | 35 void* CSSMCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) { |
| 36 return calloc(num, size); | 36 return calloc(num, size); |
| 37 } | 37 } |
| 38 | 38 |
| 39 class CSSMInitSingleton { | 39 class CSSMInitSingleton { |
| 40 public: | 40 public: |
| 41 static CSSMInitSingleton* GetInstance() { | 41 static CSSMInitSingleton* GetInstance() { |
| 42 return Singleton<CSSMInitSingleton, | 42 return base::Singleton<CSSMInitSingleton, base::LeakySingletonTraits< |
| 43 LeakySingletonTraits<CSSMInitSingleton> >::get(); | 43 CSSMInitSingleton>>::get(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 CSSM_CSP_HANDLE csp_handle() const { return csp_handle_; } | 46 CSSM_CSP_HANDLE csp_handle() const { return csp_handle_; } |
| 47 CSSM_CL_HANDLE cl_handle() const { return cl_handle_; } | 47 CSSM_CL_HANDLE cl_handle() const { return cl_handle_; } |
| 48 CSSM_TP_HANDLE tp_handle() const { return tp_handle_; } | 48 CSSM_TP_HANDLE tp_handle() const { return tp_handle_; } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 CSSMInitSingleton() | 51 CSSMInitSingleton() |
| 52 : inited_(false), csp_loaded_(false), cl_loaded_(false), | 52 : inited_(false), csp_loaded_(false), cl_loaded_(false), |
| 53 tp_loaded_(false), csp_handle_(CSSM_INVALID_HANDLE), | 53 tp_loaded_(false), csp_handle_(CSSM_INVALID_HANDLE), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool inited_; // True if CSSM_Init has been called successfully. | 145 bool inited_; // True if CSSM_Init has been called successfully. |
| 146 bool csp_loaded_; // True if gGuidAppleCSP has been loaded | 146 bool csp_loaded_; // True if gGuidAppleCSP has been loaded |
| 147 bool cl_loaded_; // True if gGuidAppleX509CL has been loaded. | 147 bool cl_loaded_; // True if gGuidAppleX509CL has been loaded. |
| 148 bool tp_loaded_; // True if gGuidAppleX509TP has been loaded. | 148 bool tp_loaded_; // True if gGuidAppleX509TP has been loaded. |
| 149 CSSM_CSP_HANDLE csp_handle_; | 149 CSSM_CSP_HANDLE csp_handle_; |
| 150 CSSM_CL_HANDLE cl_handle_; | 150 CSSM_CL_HANDLE cl_handle_; |
| 151 CSSM_TP_HANDLE tp_handle_; | 151 CSSM_TP_HANDLE tp_handle_; |
| 152 | 152 |
| 153 friend struct DefaultSingletonTraits<CSSMInitSingleton>; | 153 friend struct base::DefaultSingletonTraits<CSSMInitSingleton>; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 } // namespace | 156 } // namespace |
| 157 | 157 |
| 158 namespace crypto { | 158 namespace crypto { |
| 159 | 159 |
| 160 void EnsureCSSMInit() { | 160 void EnsureCSSMInit() { |
| 161 CSSMInitSingleton::GetInstance(); | 161 CSSMInitSingleton::GetInstance(); |
| 162 } | 162 } |
| 163 | 163 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 195 } |
| 196 | 196 |
| 197 ScopedCSSMData::~ScopedCSSMData() { | 197 ScopedCSSMData::~ScopedCSSMData() { |
| 198 if (data_.Data) { | 198 if (data_.Data) { |
| 199 CSSMFree(data_.Data); | 199 CSSMFree(data_.Data); |
| 200 data_.Data = NULL; | 200 data_.Data = NULL; |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace crypto | 204 } // namespace crypto |
| OLD | NEW |