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

Unified Diff: content/browser/loader/resource_request_info_impl.cc

Issue 2798953002: [PageLoadMetrics] Keep track of Ad Sizes on Pages (Closed)
Patch Set: Updates and address Ojan's comments Created 3 years, 8 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
Index: content/browser/loader/resource_request_info_impl.cc
diff --git a/content/browser/loader/resource_request_info_impl.cc b/content/browser/loader/resource_request_info_impl.cc
index 2f4ffd4f1139ac64d036e6e92f18eb8e8bc1caa2..2a2114109fd267f821c8543b5b5abcda8976c8a4 100644
--- a/content/browser/loader/resource_request_info_impl.cc
+++ b/content/browser/loader/resource_request_info_impl.cc
@@ -30,6 +30,15 @@ WebContents* GetWebContentsFromFTNID(int frame_tree_node_id) {
return WebContentsImpl::FromFrameTreeNode(frame_tree_node);
}
+RenderFrameHost* GetRenderFrameHostFromFTNID(int frame_tree_node_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ FrameTreeNode* frame_tree_node =
+ FrameTreeNode::GloballyFindByID(frame_tree_node_id);
+ if (!frame_tree_node)
+ return nullptr;
+ return frame_tree_node->current_frame_host();
+}
+
} // namespace
// ----------------------------------------------------------------------------
@@ -212,6 +221,29 @@ ResourceRequestInfoImpl::GetWebContentsGetterForRequest() const {
render_process_host_id, render_frame_host_id);
}
+ResourceRequestInfo::RenderFrameHostGetter
+ResourceRequestInfoImpl::GetRenderFrameHostGetterForRequest() const {
+ // PlzNavigate: navigation requests are created with a valid FrameTreeNode
+ // ID and invalid RenderProcessHost and RenderFrameHost IDs. The
+ // FrameTreeNode ID should be used to access the RenderFrameHost.
+ if (frame_tree_node_id_ != -1) {
+ DCHECK(IsBrowserSideNavigationEnabled());
+ return base::Bind(&GetRenderFrameHostFromFTNID, frame_tree_node_id_);
+ }
+
+ // In other cases, use the RenderProcessHost ID + RenderFrameHost ID to get
+ // the WebContents.
+ int render_process_host_id = -1;
+ int render_frame_host_id = -1;
+ if (!GetAssociatedRenderFrame(&render_process_host_id,
+ &render_frame_host_id)) {
+ NOTREACHED();
+ }
+
+ return base::Bind(&RenderFrameHost::FromID, render_process_host_id,
+ render_frame_host_id);
+}
+
ResourceContext* ResourceRequestInfoImpl::GetContext() const {
return context_;
}

Powered by Google App Engine
This is Rietveld 408576698