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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2227723002: predictors: Also track "no-cache" and "must-revalidate" resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 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 | « chrome/browser/predictors/resource_prefetch_predictor.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/predictors/resource_prefetch_predictor.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
index 497a359675382ad9b1b6580fae3483bbed7f5ca5..bed0510e491b44398ac080b89a6ddf1650d5fa49 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
@@ -63,7 +63,7 @@ enum ResourceStatus {
RESOURCE_STATUS_UNSUPPORTED_RESOURCE_TYPE = 4,
RESOURCE_STATUS_NOT_GET = 8,
RESOURCE_STATUS_URL_TOO_LONG = 16,
- RESOURCE_STATUS_NOT_CACHEABLE = 32,
+ RESOURCE_STATUS_NO_STORE = 32,
RESOURCE_STATUS_HEADERS_MISSING = 64,
RESOURCE_STATUS_MAX = 128,
};
@@ -280,12 +280,8 @@ bool ResourcePrefetchPredictor::IsHandledSubresource(
if (!response->response_info().headers.get())
resource_status |= RESOURCE_STATUS_HEADERS_MISSING;
- if (!IsCacheable(response))
- resource_status |= RESOURCE_STATUS_NOT_CACHEABLE;
-
- UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ResourceStatus",
- resource_status,
- RESOURCE_STATUS_MAX);
+ if (IsNoStore(response))
+ resource_status |= RESOURCE_STATUS_NO_STORE;
return resource_status == 0;
}
@@ -312,20 +308,14 @@ bool ResourcePrefetchPredictor::IsHandledResourceType(
}
// static
-bool ResourcePrefetchPredictor::IsCacheable(const net::URLRequest* response) {
+bool ResourcePrefetchPredictor::IsNoStore(const net::URLRequest* response) {
if (response->was_cached())
- return true;
+ return false;
- // For non cached responses, we will ensure that the freshness lifetime is
- // some sane value.
const net::HttpResponseInfo& response_info = response->response_info();
if (!response_info.headers.get())
return false;
- base::Time response_time(response_info.response_time);
- response_time += base::TimeDelta::FromSeconds(1);
- base::TimeDelta freshness =
- response_info.headers->GetFreshnessLifetimes(response_time).freshness;
- return freshness > base::TimeDelta();
+ return response_info.headers->HasHeaderValue("cache-control", "no-store");
}
// static
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698