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

Unified Diff: net/http/disk_based_cert_cache.h

Issue 361513003: Improving and adding an in-memory MRU cache to DiskBasedCertCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DBCC_Implement
Patch Set: Improved documentation. Created 6 years, 6 months 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 | « no previous file | net/http/disk_based_cert_cache.cc » ('j') | net/http/disk_based_cert_cache.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/disk_based_cert_cache.h
diff --git a/net/http/disk_based_cert_cache.h b/net/http/disk_based_cert_cache.h
index 302ac5cf7fe7a8d7aa259a4d36aac1b7ced5abd2..6868cdbc4f87f371b262de48648bd0f7a6adcde2 100644
--- a/net/http/disk_based_cert_cache.h
+++ b/net/http/disk_based_cert_cache.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/containers/hash_tables.h"
+#include "base/containers/mru_cache.h"
#include "base/memory/weak_ptr.h"
#include "net/base/net_export.h"
#include "net/cert/x509_certificate.h"
@@ -50,6 +51,34 @@ class NET_EXPORT_PRIVATE DiskBasedCertCache {
class ReadWorker;
class WriteWorker;
+ // A functor used to free an OSCertHandle. Used by the MRUCertCache.
+ class CertFree {
+ public:
+ void operator()(X509Certificate::OSCertHandle cert_handle) {
+ X509Certificate::FreeOSCertHandle(cert_handle);
+ }
+ };
+
+ // An in-memory cache that is used to prevent redundant reads and writes
+ // to and from the disk cache.
+ class MRUCertCache : public base::MRUCacheBase<std::string,
wtc 2014/07/01 02:11:31 Since MRUCertCache doesn't have any new method or
+ X509Certificate::OSCertHandle,
+ CertFree> {
+ private:
+ typedef base::MRUCacheBase<std::string,
+ X509Certificate::OSCertHandle,
+ CertFree> ParentType;
+
+ public:
+ // |max_size| is the maximum number of OSCertHandles to be stored
+ // at one time.
+ explicit MRUCertCache(typename ParentType::size_type max_size)
+ : ParentType(max_size) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MRUCertCache);
+ };
+
// ReadWorkerMap and WriteWorkerMap map cache keys to their
// corresponding Workers.
typedef base::hash_map<std::string, ReadWorker*> ReadWorkerMap;
@@ -57,14 +86,18 @@ class NET_EXPORT_PRIVATE DiskBasedCertCache {
// FinishedReadOperation and FinishedWriteOperation are used by callbacks
// given to the workers to signal the DiskBasedCertCache they have completed
- // their work.
- void FinishedReadOperation(const std::string& key);
+ // their work. FinishedReadOperation also stores the retrieved OSCertHandle
+ // in |mru_cert_cache_|.
+ void FinishedReadOperation(const std::string& key,
+ X509Certificate::OSCertHandle cert_handle);
void FinishedWriteOperation(const std::string& key);
+ disk_cache::Backend* backend_;
+
ReadWorkerMap read_worker_map_;
WriteWorkerMap write_worker_map_;
+ MRUCertCache mru_cert_cache_;
- disk_cache::Backend* backend_;
base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DiskBasedCertCache);
};
« no previous file with comments | « no previous file | net/http/disk_based_cert_cache.cc » ('j') | net/http/disk_based_cert_cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698