diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 21:25:38 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 21:25:38 +0000 |
commit | 82e8e2b5b879cd414e48e6418fb1a693093866e2 (patch) | |
tree | 513b4c2186f8be29e2d8a7d56e76a75d96dbf437 /net/base/x509_certificate_mac.cc | |
parent | 48a5faa6500b6c6055348abf1540cbb06c721f33 (diff) | |
download | chromium_src-82e8e2b5b879cd414e48e6418fb1a693093866e2.zip chromium_src-82e8e2b5b879cd414e48e6418fb1a693093866e2.tar.gz chromium_src-82e8e2b5b879cd414e48e6418fb1a693093866e2.tar.bz2 |
Disallow Singleton and LazyInstance on non-joinable threads.
Fix all known instances or explicitly allow them. Usually the fix involves switching from Default traits to Lazy traits.
BUG=61753
TEST=none
Review URL: http://codereview.chromium.org/4635012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/x509_certificate_mac.cc')
-rw-r--r-- | net/base/x509_certificate_mac.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc index a2a0eea..2a604ee 100644 --- a/net/base/x509_certificate_mac.cc +++ b/net/base/x509_certificate_mac.cc @@ -8,6 +8,7 @@ #include <Security/Security.h> #include <time.h> +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/pickle.h" #include "base/mac/scoped_cftyperef.h" @@ -21,6 +22,8 @@ using base::Time; namespace net { +namespace { + class MacTrustedCertificates { public: // Sets the trusted root certificate used by tests. Call with |cert| set @@ -57,7 +60,7 @@ class MacTrustedCertificates { return merged_array; } private: - friend struct DefaultSingletonTraits<MacTrustedCertificates>; + friend struct base::DefaultLazyInstanceTraits<MacTrustedCertificates>; // Obtain an instance of MacTrustedCertificates via the singleton // interface. @@ -73,11 +76,9 @@ class MacTrustedCertificates { DISALLOW_COPY_AND_ASSIGN(MacTrustedCertificates); }; -void SetMacTestCertificate(X509Certificate* cert) { - Singleton<MacTrustedCertificates>::get()->SetTestCertificate(cert); -} - -namespace { +base::LazyInstance<MacTrustedCertificates, + base::LeakyLazyInstanceTraits<MacTrustedCertificates> > + g_mac_trusted_certificates(base::LINKER_INITIALIZED); typedef OSStatus (*SecTrustCopyExtendedResultFuncPtr)(SecTrustRef, CFDictionaryRef*); @@ -443,6 +444,10 @@ void AddCertificatesFromBytes(const char* data, size_t length, } // namespace +void SetMacTestCertificate(X509Certificate* cert) { + g_mac_trusted_certificates.Get().SetTestCertificate(cert); +} + void X509Certificate::Initialize() { const CSSM_X509_NAME* name; OSStatus status = SecCertificateGetSubject(cert_handle_, &name); @@ -545,7 +550,7 @@ int X509Certificate::Verify(const std::string& hostname, int flags, // Set the trusted anchor certificates for the SecTrustRef by merging the // system trust anchors and the test root certificate. CFArrayRef anchor_array = - Singleton<MacTrustedCertificates>::get()->CopyTrustedCertificateArray(); + g_mac_trusted_certificates.Get().CopyTrustedCertificateArray(); ScopedCFTypeRef<CFArrayRef> scoped_anchor_array(anchor_array); if (anchor_array) { status = SecTrustSetAnchorCertificates(trust_ref, anchor_array); |