Chromium Code Reviews| 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..a7c51001b2efd38b997d5798120d7048e10ceedf 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,28 @@ class NET_EXPORT_PRIVATE DiskBasedCertCache { |
| void Set(const X509Certificate::OSCertHandle cert_handle, |
| const SetCallback& cb); |
| + // These functions intended for testing purposes only. |
|
wtc
2014/07/02 20:51:50
Nit: please document what they return.
Ryan Sleevi
2014/07/02 21:49:58
For testing, we prefer to use friend classes to a
rvargas (doing something else)
2014/07/02 22:14:39
nit: If it is important that the methods should be
|
| + int MemCacheHits() { return mem_cache_hits_; } |
| + int MemCacheMisses() { return mem_cache_misses_; } |
|
wtc
2014/07/02 20:51:50
1. These methods should be declared const.
2. The
Ryan Sleevi
2014/07/02 21:49:58
http://www.chromium.org/developers/coding-style#TO
|
| + |
| private: |
| 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); |
| + } |
| + }; |
|
Ryan Sleevi
2014/07/02 21:49:58
You should be able to just declare this class, and
|
| + |
| + // 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 +77,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_; |
|
wtc
2014/07/02 20:51:50
Ricardo: does the disk cache already have an inter
rvargas (doing something else)
2014/07/02 22:14:39
no, it doesn't
|
| + |
| + int mem_cache_hits_; |
| + int mem_cache_misses_; |
| - disk_cache::Backend* backend_; |
| base::WeakPtrFactory<DiskBasedCertCache> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(DiskBasedCertCache); |
| }; |