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

Unified Diff: net/http/disk_based_cert_cache.cc

Issue 378063002: Adding cache hit/miss histograms to DiskBasedCertCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DBCC_MRU_Implement
Patch Set: Created 6 years, 5 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 | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698