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

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: Removed static cast. 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..5719cc649b5322f9284af753f29b70fe81adcbe4 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"
@@ -46,10 +47,29 @@ class NET_EXPORT_PRIVATE DiskBasedCertCache {
void Set(const X509Certificate::OSCertHandle cert_handle,
const SetCallback& cb);
+ // Returns the number of in-memory MRU cache hits that have occured
wtc 2014/07/03 02:37:13 Nit: occured => occurred Also on line 54.
+ // on Set and Get operations. Intended for test purposes only.
+ size_t mem_cache_hits_for_testing() const { return mem_cache_hits_; }
+
+ // Returns the number of in-memory MRU cache misses that have occured
+ // on Set and Get operations. Intended for test purposes only.
+ size_t mem_cache_misses_for_testing() const { return mem_cache_misses_; }
+
private:
class ReadWorker;
class WriteWorker;
+ // A functor used to free an OSCertHandle. Used by the MRUCertCache.
+ struct CertFree {
+ void operator()(X509Certificate::OSCertHandle cert_handle);
+ };
+
+ // An in-memory cache that is used to prevent redundant reads and writes
+ // to and from the disk cache.
+ typedef base::MRUCacheBase<std::string,
+ X509Certificate::OSCertHandle,
+ CertFree> MRUCertCache;
+
// ReadWorkerMap and WriteWorkerMap map cache keys to their
// corresponding Workers.
typedef base::hash_map<std::string, ReadWorker*> ReadWorkerMap;
@@ -58,13 +78,20 @@ 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);
- void FinishedWriteOperation(const std::string& key);
+ void FinishedReadOperation(const std::string& key,
+ X509Certificate::OSCertHandle cert_handle);
+ void FinishedWriteOperation(const std::string& key,
+ X509Certificate::OSCertHandle cert_handle);
+
+ disk_cache::Backend* backend_;
ReadWorkerMap read_worker_map_;
WriteWorkerMap write_worker_map_;
+ MRUCertCache mru_cert_cache_;
+
+ int mem_cache_hits_;
+ int mem_cache_misses_;
- 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