Commit 297307a0 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Mark RenderFrameHostImpl.parent_ as const.

I added a helper GetParentRenderFrameHost because the previous code
would crash if current_render_frame_host() was nullptr. This ensures
that we still crash if that ever happens.

Change-Id: I0f9d3ef2f5cb1a86a247f5fe5db8b6d9fe47d31a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041153Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740616}
parent af7c62c5
...@@ -880,7 +880,10 @@ RenderFrameHostImpl::RenderFrameHostImpl( ...@@ -880,7 +880,10 @@ RenderFrameHostImpl::RenderFrameHostImpl(
process_(site_instance->GetProcess()), process_(site_instance->GetProcess()),
frame_tree_(frame_tree), frame_tree_(frame_tree),
frame_tree_node_(frame_tree_node), frame_tree_node_(frame_tree_node),
parent_(nullptr), // If it has a parent, that parent must have a RFH.
parent_(frame_tree_node_->parent()
? frame_tree_node_->parent()->current_frame_host()
: nullptr),
routing_id_(routing_id), routing_id_(routing_id),
is_waiting_for_unload_ack_(false), is_waiting_for_unload_ack_(false),
render_frame_created_(false), render_frame_created_(false),
...@@ -924,11 +927,6 @@ RenderFrameHostImpl::RenderFrameHostImpl( ...@@ -924,11 +927,6 @@ RenderFrameHostImpl::RenderFrameHostImpl(
GetSiteInstance()->IncrementActiveFrameCount(); GetSiteInstance()->IncrementActiveFrameCount();
if (frame_tree_node_->parent()) { if (frame_tree_node_->parent()) {
// Keep track of the parent RenderFrameHost, which shouldn't change even if
// this RenderFrameHost is on the pending deletion list and the parent
// FrameTreeNode has changed its current RenderFrameHost.
parent_ = frame_tree_node_->parent()->current_frame_host();
cross_origin_embedder_policy_ = parent_->cross_origin_embedder_policy(); cross_origin_embedder_policy_ = parent_->cross_origin_embedder_policy();
// New child frames should inherit the nav_entry_id of their parent. // New child frames should inherit the nav_entry_id of their parent.
......
...@@ -2110,8 +2110,10 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -2110,8 +2110,10 @@ class CONTENT_EXPORT RenderFrameHostImpl
// The active parent RenderFrameHost for this frame, if it is a subframe. // The active parent RenderFrameHost for this frame, if it is a subframe.
// Null for the main frame. This is cached because the parent FrameTreeNode // Null for the main frame. This is cached because the parent FrameTreeNode
// may change its current RenderFrameHost while this child is pending // may change its current RenderFrameHost while this child is pending
// deletion, and GetParent() should never return a different value. // deletion, and GetParent() should never return a different value, even if
RenderFrameHostImpl* parent_; // this RenderFrameHost is on the pending deletion list and the parent
// FrameTreeNode has changed its current RenderFrameHost.
RenderFrameHostImpl* const parent_;
// Track this frame's last committed URL. // Track this frame's last committed URL.
GURL last_committed_url_; GURL last_committed_url_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment