summaryrefslogtreecommitdiffstats
path: root/net/base/x509_certificate.h
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 21:58:45 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 21:58:45 +0000
commitd4f7e76644f684d0e9395fa8225e0d1c607de241 (patch)
tree037f5dd8b63ae6dcb79a7850c5a41dee128dafd4 /net/base/x509_certificate.h
parent9f8a2077e3c53da309c3e9b3698eff577877ad8c (diff)
downloadchromium_src-d4f7e76644f684d0e9395fa8225e0d1c607de241.zip
chromium_src-d4f7e76644f684d0e9395fa8225e0d1c607de241.tar.gz
chromium_src-d4f7e76644f684d0e9395fa8225e0d1c607de241.tar.bz2
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
Diffstat (limited to 'net/base/x509_certificate.h')
-rw-r--r--net/base/x509_certificate.h34
1 files changed, 26 insertions, 8 deletions
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 <map>
#include <set>
#include <string>
#include <vector>
#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<X509Certificate> {
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<Fingerprint, X509Certificate*, FingerprintLessThan>
+ CertMap;
+
+ // Obtain an instance of X509Certificate::Cache via GetInstance().
+ Cache() { }
+ friend struct DefaultSingletonTraits<Cache>;
+
+ // 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<X509Certificate> {
// 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_;