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..b67f8b13dda1f9735fa0125b2980ddd562a31514 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 RecordMemCacheHit(bool hit) { |
+ UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.MemCacheHit", hit); |
+} |
+ |
+void RecordDiskCacheHit(bool hit) { |
+ UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.DiskCacheHit", hit); |
+} |
+ |
} // namespace |
// WriteWorkers represent pending Set jobs in the DiskBasedCertCache. Each |
@@ -428,8 +437,14 @@ int DiskBasedCertCache::ReadWorker::DoOpen() { |
} |
int DiskBasedCertCache::ReadWorker::DoOpenComplete(int rv) { |
- if (rv < 0) |
+ if (rv < 0) { |
+ // Errors other than CACHE_MISS are not recorded as either a hit |
+ // or a miss. |
+ if (rv == ERR_CACHE_MISS) |
+ RecordDiskCacheHit(false); |
return rv; |
+ } |
+ RecordDiskCacheHit(true); |
state_ = STATE_READ; |
return OK; |
@@ -506,10 +521,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()) { |
+ RecordMemCacheHit(true); |
++mem_cache_hits_; |
cb.Run(mru_it->second); |
return; |
} |
+ RecordMemCacheHit(false); |
++mem_cache_misses_; |
ReadWorkerMap::iterator it = read_worker_map_.find(key); |