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

Unified Diff: net/http/http_cache_transaction.cc

Issue 356953003: Adding DiskBasedCertCache to HttpCache (+UMA). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@current
Patch Set: 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
« net/http/http_cache_transaction.h ('K') | « net/http/http_cache_transaction.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index bf791118be88b704966c7d3a886d5fcc4c924f63..4b944c88935c08f0526e99d714c0a8dff44fcf00 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -46,6 +46,26 @@ using base::TimeDelta;
using base::TimeTicks;
namespace {
+// used with DiskBasedCertCached objects. TODO(brandonsalmon) start
+// storing cache keys so that this doesn't need to be done.
Ryan Sleevi 2014/06/26 19:56:02 This comment can use some style guide love. Compl
+std::string GetCacheKeyToCert(
+ const net::X509Certificate::OSCertHandle cert_handle) {
+ net::SHA1HashValue fingerprint =
+ net::X509Certificate::CalculateFingerprint(cert_handle);
+
+ return "cert:" +
+ base::HexEncode(fingerprint.data, arraysize(fingerprint.data));
+}
+
+void OnCertReadIOComplete(net::X509Certificate::OSCertHandle cert_handle) {
+ bool success = (cert_handle != NULL);
+ UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.ReadSuccess", success);
+}
+
+void OnCertWriteIOComplete(const std::string& key) {
+ bool success = (key!=std::string());
+ UMA_HISTOGRAM_BOOLEAN("DiskBasedCertCache.WriteSuccess", success);
+}
// From http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-21#section-6
// a "non-error response" is one with a 2xx (Successful) or 3xx
@@ -190,9 +210,7 @@ static bool HeaderMatches(const HttpRequestHeaders& headers,
//-----------------------------------------------------------------------------
-HttpCache::Transaction::Transaction(
- RequestPriority priority,
- HttpCache* cache)
+HttpCache::Transaction::Transaction(RequestPriority priority, HttpCache* cache)
: next_state_(STATE_NONE),
request_(NULL),
priority_(priority),
@@ -218,8 +236,10 @@ HttpCache::Transaction::Transaction(
effective_load_flags_(0),
write_len_(0),
weak_factory_(this),
- io_callback_(base::Bind(&Transaction::OnIOComplete,
- weak_factory_.GetWeakPtr())),
+ io_callback_(
+ base::Bind(&Transaction::OnIOComplete, weak_factory_.GetWeakPtr())),
+ cert_read_io_callback_(base::Bind(&OnCertReadIOComplete)),
+ cert_write_io_callback_(base::Bind(&OnCertWriteIOComplete)),
transaction_pattern_(PATTERN_UNDEFINED),
total_received_bytes_(0),
websocket_handshake_stream_base_create_helper_(NULL) {
@@ -1495,6 +1515,12 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
return OnCacheReadError(result, true);
}
+ if(response_.ssl_info.is_valid()) {
+ std::string key = GetCacheKeyToCert(
+ response_.ssl_info.cert->os_cert_handle());
+ cache_->CertCache()->Get(key, cert_read_io_callback_);
Ryan Sleevi 2014/06/26 19:56:02 BUG? You're not checking the intermediates (from t
+ }
+
// Some resources may have slipped in as truncated when they're not.
int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex);
if (response_.headers->GetContentLength() == current_size)
@@ -2327,6 +2353,11 @@ int HttpCache::Transaction::WriteResponseInfoToEntry(bool truncated) {
return OK;
}
+ if (response_.ssl_info.is_valid()) {
+ cache_->CertCache()->Set(response_.ssl_info.cert->os_cert_handle(),
+ cert_write_io_callback_);
Ryan Sleevi 2014/06/26 19:56:02 STYLE: Indent style BUG: Same as above, not checki
+ }
+
// When writing headers, we normally only write the non-transient
// headers; when in record mode, record everything.
bool skip_transient_headers = (cache_->mode() != RECORD);
« net/http/http_cache_transaction.h ('K') | « net/http/http_cache_transaction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698