| Index: net/base/x509_certificate_mac.cc
|
| ===================================================================
|
| --- net/base/x509_certificate_mac.cc (revision 66806)
|
| +++ net/base/x509_certificate_mac.cc (working copy)
|
| @@ -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 @@
|
|
|
| namespace net {
|
|
|
| +namespace {
|
| +
|
| class MacTrustedCertificates {
|
| public:
|
| // Sets the trusted root certificate used by tests. Call with |cert| set
|
| @@ -57,7 +60,7 @@
|
| return merged_array;
|
| }
|
| private:
|
| - friend struct DefaultSingletonTraits<MacTrustedCertificates>;
|
| + friend struct base::DefaultLazyInstanceTraits<MacTrustedCertificates>;
|
|
|
| // Obtain an instance of MacTrustedCertificates via the singleton
|
| // interface.
|
| @@ -73,12 +76,10 @@
|
| DISALLOW_COPY_AND_ASSIGN(MacTrustedCertificates);
|
| };
|
|
|
| -void SetMacTestCertificate(X509Certificate* cert) {
|
| - Singleton<MacTrustedCertificates>::get()->SetTestCertificate(cert);
|
| -}
|
| +base::LazyInstance<MacTrustedCertificates,
|
| + base::LeakyLazyInstanceTraits<MacTrustedCertificates> >
|
| + g_mac_trusted_certificates(base::LINKER_INITIALIZED);
|
|
|
| -namespace {
|
| -
|
| typedef OSStatus (*SecTrustCopyExtendedResultFuncPtr)(SecTrustRef,
|
| CFDictionaryRef*);
|
|
|
| @@ -443,6 +444,10 @@
|
|
|
| } // 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 @@
|
| // 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);
|
|
|