Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: net/base/x509_certificate_mac.cc

Issue 5242002: Reland 66791 (change was innocent)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/x509_certificate.cc ('k') | net/ocsp/nss_ocsp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « net/base/x509_certificate.cc ('k') | net/ocsp/nss_ocsp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698