From d4f7e76644f684d0e9395fa8225e0d1c607de241 Mon Sep 17 00:00:00 2001 From: "avi@google.com" Date: Tue, 23 Sep 2008 21:58:45 +0000 Subject: Refactoring out common code in the X.509 cert handling Review URL: http://codereview.chromium.org/4040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2525 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/x509_certificate.h | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'net/base/x509_certificate.h') diff --git a/net/base/x509_certificate.h b/net/base/x509_certificate.h index c9f872a..e383532 100644 --- a/net/base/x509_certificate.h +++ b/net/base/x509_certificate.h @@ -5,11 +5,13 @@ #ifndef NET_BASE_X509_CERTIFICATE_H_ #define NET_BASE_X509_CERTIFICATE_H_ +#include #include #include #include #include "base/ref_counted.h" +#include "base/singleton.h" #include "base/time.h" #if defined(OS_WIN) @@ -166,7 +168,30 @@ class X509Certificate : public base::RefCountedThreadSafe { private: // A cache of X509Certificate objects. - class Cache; + class Cache { + public: + static Cache* GetInstance(); + void Insert(X509Certificate* cert); + void Remove(X509Certificate* cert); + X509Certificate* Find(const Fingerprint& fingerprint); + + private: + typedef std::map + CertMap; + + // Obtain an instance of X509Certificate::Cache via GetInstance(). + Cache() { } + friend struct DefaultSingletonTraits; + + // You must acquire this lock before using any private data of this object. + // You must not block while holding this lock. + Lock lock_; + + // The certificate cache. You must acquire |lock_| before using |cache_|. + CertMap cache_; + + DISALLOW_COPY_AND_ASSIGN(Cache); + }; // Construct an X509Certificate from a handle to the certificate object // in the underlying crypto library. @@ -178,13 +203,6 @@ class X509Certificate : public base::RefCountedThreadSafe { // Common object initialization code. Called by the constructors only. void Initialize(); -#if defined(OS_WIN) - // Helper function to parse a principal from a WinInet description of that - // principal. - static void ParsePrincipal(const std::string& description, - Principal* principal); -#endif - // The subject of the certificate. Principal subject_; -- cgit v1.1