summaryrefslogtreecommitdiffstats
path: root/base/crypto
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-04 23:00:10 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-04 23:00:10 +0000
commit864b558217c75dbdebea9db3568056292d4cd274 (patch)
tree06bd9f240065ed47fab9ff415ae4cd49f21facf1 /base/crypto
parent8c9e61a02aad4d8baa0f75ae7ac2f2f1963fffd6 (diff)
downloadchromium_src-864b558217c75dbdebea9db3568056292d4cd274.zip
chromium_src-864b558217c75dbdebea9db3568056292d4cd274.tar.gz
chromium_src-864b558217c75dbdebea9db3568056292d4cd274.tar.bz2
This CL add a GetInstance() method to singleton classes instead of relying on the callers to use Singleton<T>.
In some cases I have used the LazyInstance<T> pattern as that was simpler. This is a small step towards making all singleton classes use the Singleton<T> pattern within their code and not expect the callers to know about it. I have selected all files under src/app and src/base which use Singleton<T> in this CL. Once this CL goes in I'll work on the rest of the files. BUG=65298 TEST=all existing tests should continue to pass. Review URL: http://codereview.chromium.org/5527004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/crypto')
-rw-r--r--base/crypto/cssm_init.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/base/crypto/cssm_init.cc b/base/crypto/cssm_init.cc
index b04cbe7..46a6ffe 100644
--- a/base/crypto/cssm_init.cc
+++ b/base/crypto/cssm_init.cc
@@ -22,6 +22,13 @@ namespace {
class CSSMInitSingleton {
public:
+ static CSSMInitSingleton* GetInstance() {
+ return Singleton<CSSMInitSingleton>::get();
+ }
+
+ CSSM_CSP_HANDLE csp_handle() const {return csp_handle_;}
+
+ private:
CSSMInitSingleton() : inited_(false), loaded_(false), csp_handle_(NULL) {
static CSSM_VERSION version = {2, 0};
// TODO(wtc): what should our caller GUID be?
@@ -68,18 +75,21 @@ class CSSMInitSingleton {
}
}
- CSSM_CSP_HANDLE csp_handle() const {return csp_handle_;}
-
- private:
bool inited_; // True if CSSM_Init has been called successfully.
bool loaded_; // True if CSSM_ModuleLoad has been called successfully.
CSSM_CSP_HANDLE csp_handle_;
+
+ friend struct DefaultSingletonTraits<CSSMInitSingleton>;
};
// This singleton is separate as it pertains to Apple's wrappers over
// their own CSSM handles, as opposed to our own CSSM_CSP_HANDLE.
class SecurityServicesSingleton {
public:
+ static SecurityServicesSingleton* GetInstance() {
+ return Singleton<SecurityServicesSingleton>::get();
+ }
+
~SecurityServicesSingleton() {}
Lock& lock() { return lock_; }
@@ -100,11 +110,11 @@ class SecurityServicesSingleton {
namespace base {
void EnsureCSSMInit() {
- Singleton<CSSMInitSingleton>::get();
+ CSSMInitSingleton::GetInstance();
}
CSSM_CSP_HANDLE GetSharedCSPHandle() {
- return Singleton<CSSMInitSingleton>::get()->csp_handle();
+ return CSSMInitSingleton::GetInstance()->csp_handle();
}
void* CSSMMalloc(CSSM_SIZE size, void *alloc_ref) {
@@ -145,7 +155,7 @@ void LogCSSMError(const char *fn_name, CSSM_RETURN err) {
}
Lock& GetMacSecurityServicesLock() {
- return Singleton<SecurityServicesSingleton>::get()->lock();
+ return SecurityServicesSingleton::GetInstance()->lock();
}
} // namespace base