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

Unified Diff: net/http/http_cache_transaction.cc

Issue 2005753004: Record the number of freshness periods since a stale HttpCache entry was last used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 4 years, 7 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 | « net/http/http_cache_transaction.h ('k') | net/http/mock_http_cache.cc » ('j') | 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 420092620705381184e2bce0a6638342ede00d65..f5f7d599e6b0b3b4e8af451be83d851598c751b9 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -1134,6 +1134,8 @@ int HttpCache::Transaction::DoAddToEntryComplete(int result) {
return OK;
}
+ open_entry_last_used_ = entry_->disk_entry->GetLastUsed();
+
if (result != OK) {
NOTREACHED();
return result;
@@ -2190,11 +2192,14 @@ ValidationType HttpCache::Transaction::RequiresValidation() {
cache_->clock_->Now());
if (validation_required_by_headers != VALIDATION_NONE) {
- validation_cause_ =
- response_.headers->GetFreshnessLifetimes(response_.response_time)
- .freshness == base::TimeDelta()
- ? VALIDATION_CAUSE_ZERO_FRESHNESS
- : VALIDATION_CAUSE_STALE;
+ HttpResponseHeaders::FreshnessLifetimes lifetimes =
+ response_.headers->GetFreshnessLifetimes(response_.response_time);
+ if (lifetimes.freshness == base::TimeDelta()) {
+ validation_cause_ = VALIDATION_CAUSE_ZERO_FRESHNESS;
+ } else {
+ validation_cause_ = VALIDATION_CAUSE_STALE;
+ stale_entry_freshness_ = lifetimes.freshness;
+ }
}
if (validation_required_by_headers == VALIDATION_ASYNCHRONOUS) {
@@ -2790,6 +2795,19 @@ void HttpCache::Transaction::RecordHistograms() {
}
}
+ if ((validation_request ||
+ transaction_pattern_ == PATTERN_ENTRY_CANT_CONDITIONALIZE) &&
+ validation_cause_ == VALIDATION_CAUSE_STALE) {
+ // For stale entries, record how many freshness periods have elapsed since
+ // the entry was last used.
+ DCHECK(!open_entry_last_used_.is_null());
+ DCHECK(!stale_entry_freshness_.is_zero());
+
+ base::TimeDelta time_since_use = base::Time::Now() - open_entry_last_used_;
+ UMA_HISTOGRAM_COUNTS("HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed",
+ (time_since_use * 1000) / stale_entry_freshness_);
+ }
+
UMA_HISTOGRAM_ENUMERATION(
"HttpCache.Pattern", transaction_pattern_, PATTERN_MAX);
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698