Chromium Code Reviews| Index: net/http/disk_based_cert_cache.cc |
| diff --git a/net/http/disk_based_cert_cache.cc b/net/http/disk_based_cert_cache.cc |
| index 606407999e65eb9339f67504aca2f1fb924573bf..a04bb9b0ff9331d1c025c11ac1dd9f4737b042b3 100644 |
| --- a/net/http/disk_based_cert_cache.cc |
| +++ b/net/http/disk_based_cert_cache.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/bind.h" |
| #include "base/callback_helpers.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/stl_util.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "net/base/io_buffer.h" |
| @@ -32,6 +33,14 @@ std::string GetCacheKeyToCert(const X509Certificate::OSCertHandle cert_handle) { |
| base::HexEncode(fingerprint.data, arraysize(fingerprint.data)); |
| } |
| +void RecordMemCacheHits(bool hit) { |
| + UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.MemCacheHits", hit); |
| +} |
| + |
| +void RecordDiskCacheHits(bool hit) { |
| + UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.DiskCacheHits", hit); |
| +} |
| + |
| } // namespace |
| // WriteWorkers represent pending Set jobs in the DiskBasedCertCache. Each |
| @@ -428,8 +437,13 @@ int DiskBasedCertCache::ReadWorker::DoOpen() { |
| } |
| int DiskBasedCertCache::ReadWorker::DoOpenComplete(int rv) { |
| + // Errors other than cache miss are not recorded as either a hit |
| + // or a miss. |
| + if (rv == ERR_CACHE_MISS) |
| + RecordDiskCacheHits(false); |
| if (rv < 0) |
| return rv; |
|
wtc
2014/07/09 14:55:36
Nit: I would structure this as follows:
if (rv
|
| + RecordDiskCacheHits(true); |
|
wtc
2014/07/09 14:55:36
This means a corrupted disk cache entry is still r
|
| state_ = STATE_READ; |
| return OK; |
| @@ -506,10 +520,12 @@ void DiskBasedCertCache::Get(const std::string& key, const GetCallback& cb) { |
| // list in the MRU cache. |
| MRUCertCache::iterator mru_it = mru_cert_cache_.Get(key); |
| if (mru_it != mru_cert_cache_.end()) { |
| + RecordMemCacheHits(true); |
| ++mem_cache_hits_; |
| cb.Run(mru_it->second); |
| return; |
| } |
| + RecordMemCacheHits(false); |
| ++mem_cache_misses_; |
| ReadWorkerMap::iterator it = read_worker_map_.find(key); |