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 ad3e824f5ea5adadb37ada20bb5fbf40412e3ae5..b26b7add827810a961b55b9b03348892d6b63380 100644 |
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc |
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc |
@@ -417,6 +417,8 @@ void ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(bool state) { |
ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary() |
: resource_type(content::RESOURCE_TYPE_LAST_TYPE), |
priority(net::IDLE), |
+ creation_time(base::TimeTicks()), |
+ before_first_contentful_paint(false), |
was_cached(false), |
has_validators(false), |
always_revalidate(false) {} |
@@ -427,6 +429,8 @@ ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary( |
resource_url(other.resource_url), |
resource_type(other.resource_type), |
priority(other.priority), |
+ creation_time(other.creation_time), |
+ before_first_contentful_paint(other.before_first_contentful_paint), |
mime_type(other.mime_type), |
was_cached(other.was_cached), |
redirect_url(other.redirect_url), |
@@ -445,6 +449,7 @@ bool ResourcePrefetchPredictor::URLRequestSummary::SummarizeResponse( |
if (!request_info) |
return false; |
+ summary->creation_time = request.creation_time(); |
summary->resource_url = request.original_url(); |
content::ResourceType resource_type_from_request = |
request_info->GetResourceType(); |
@@ -591,6 +596,22 @@ void ResourcePrefetchPredictor::RecordMainFrameLoadComplete( |
} |
} |
+void ResourcePrefetchPredictor::RecordFirstContentfulPaint( |
+ const NavigationID& navigation_id, |
+ const base::TimeDelta& first_contentful_paint) { |
+ NavigationMap::iterator nav_it = |
+ inflight_navigations_.find(navigation_id); |
+ if (nav_it == inflight_navigations_.end()) |
+ return; |
+ |
+ base::TimeTicks fcp = nav_it->first.creation_time + first_contentful_paint; |
+ for (auto& request_summary : nav_it->second->subresource_requests) { |
+ request_summary.before_first_contentful_paint = |
+ request_summary.creation_time < fcp; |
+ } |
+} |
+ |
+ |
void ResourcePrefetchPredictor::StartPrefetching(const GURL& url, |
PrefetchOrigin origin) { |
TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StartPrefetching", "url", |
@@ -1179,6 +1200,8 @@ void ResourcePrefetchPredictor::LearnNavigation( |
continue; |
ResourceData* resource_to_add = data.add_resources(); |
+ resource_to_add->set_before_first_contentful_paint( |
+ summary.before_first_contentful_paint); |
resource_to_add->set_resource_url(summary.resource_url.spec()); |
resource_to_add->set_resource_type( |
static_cast<ResourceData::ResourceType>(summary.resource_type)); |