Commit 03b4800d authored by creis's avatar creis Committed by Commit bot

Move nav_entry_id from RenderViewHost to RenderFrameHost.

We update this value for every current RFH in the FrameTree on each new
NavigationEntry commit.  This allows us to track the latest entry that
is relevant for each RFH, which is where UpdateTitle and UpdateState
messages should apply.

BUG=545219, 369661
TEST=No visible behavior change yet; will enable per-frame UpdateState.

Review URL: https://codereview.chromium.org/1425293006

Cr-Commit-Position: refs/heads/master@{#357690}
parent 031ed3ba
...@@ -145,6 +145,13 @@ bool ShouldKeepOverride(const NavigationEntry* last_entry) { ...@@ -145,6 +145,13 @@ bool ShouldKeepOverride(const NavigationEntry* last_entry) {
return last_entry && last_entry->GetIsOverridingUserAgent(); return last_entry && last_entry->GetIsOverridingUserAgent();
} }
// Helper method for FrameTree::ForEach to set the nav_entry_id on each current
// RenderFrameHost in the tree.
bool SetFrameNavEntryID(int nav_entry_id, FrameTreeNode* node) {
node->current_frame_host()->set_nav_entry_id(nav_entry_id);
return true;
}
} // namespace } // namespace
// NavigationControllerImpl ---------------------------------------------------- // NavigationControllerImpl ----------------------------------------------------
...@@ -947,13 +954,13 @@ bool NavigationControllerImpl::RendererDidNavigate( ...@@ -947,13 +954,13 @@ bool NavigationControllerImpl::RendererDidNavigate(
NotifyNavigationEntryCommitted(details); NotifyNavigationEntryCommitted(details);
// Update the RenderViewHost of the top-level RenderFrameHost's notion of what // Update the nav_entry_id for each RenderFrameHost in the tree, so that each
// entry it's showing for use later. // one knows the latest NavigationEntry it is showing (whether it has
RenderFrameHostImpl* main_frame = // committed anything in this navigation or not). This allows things like
rfh->frame_tree_node()->frame_tree()->root()->current_frame_host(); // state and title updates from RenderFrames to apply to the latest relevant
static_cast<RenderViewHostImpl*>(main_frame->GetRenderViewHost())-> // NavigationEntry.
set_nav_entry_id(active_entry->GetUniqueID()); delegate_->GetFrameTree()->ForEach(
base::Bind(&SetFrameNavEntryID, active_entry->GetUniqueID()));
return true; return true;
} }
......
...@@ -190,6 +190,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, ...@@ -190,6 +190,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
unload_ack_is_for_navigation_(false), unload_ack_is_for_navigation_(false),
is_loading_(false), is_loading_(false),
pending_commit_(false), pending_commit_(false),
nav_entry_id_(0),
accessibility_reset_token_(0), accessibility_reset_token_(0),
accessibility_reset_count_(0), accessibility_reset_count_(0),
no_create_browser_accessibility_manager_for_testing_(false), no_create_browser_accessibility_manager_for_testing_(false),
......
...@@ -254,6 +254,14 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -254,6 +254,14 @@ class CONTENT_EXPORT RenderFrameHostImpl
// TODO(creis): Make bindings frame-specific, to support cases like <webview>. // TODO(creis): Make bindings frame-specific, to support cases like <webview>.
int GetEnabledBindings(); int GetEnabledBindings();
// The unique ID of the latest NavigationEntry that this RenderFrameHost is
// showing. This may change even when this frame hasn't committed a page,
// such as for a new subframe navigation in a different frame.
int nav_entry_id() const { return nav_entry_id_; }
void set_nav_entry_id(int nav_entry_id) { nav_entry_id_ = nav_entry_id; }
// A NavigationHandle for the pending navigation in this frame, if any. This
// is cleared when the navigation commits.
NavigationHandleImpl* navigation_handle() const { NavigationHandleImpl* navigation_handle() const {
return navigation_handle_.get(); return navigation_handle_.get();
} }
...@@ -755,6 +763,13 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -755,6 +763,13 @@ class CONTENT_EXPORT RenderFrameHostImpl
// tests. // tests.
bool pending_commit_; bool pending_commit_;
// The unique ID of the latest NavigationEntry that this RenderFrameHost is
// showing. This may change even when this frame hasn't committed a page,
// such as for a new subframe navigation in a different frame. Tracking this
// allows us to send things like title and state updates to the latest
// relevant NavigationEntry.
int nav_entry_id_;
// Used to swap out or shut down this RFH when the unload event is taking too // Used to swap out or shut down this RFH when the unload event is taking too
// long to execute, depending on the number of active frames in the // long to execute, depending on the number of active frames in the
// SiteInstance. // SiteInstance.
......
...@@ -224,7 +224,6 @@ RenderViewHostImpl::RenderViewHostImpl( ...@@ -224,7 +224,6 @@ RenderViewHostImpl::RenderViewHostImpl(
waiting_for_drag_context_response_(false), waiting_for_drag_context_response_(false),
enabled_bindings_(0), enabled_bindings_(0),
page_id_(-1), page_id_(-1),
nav_entry_id_(0),
is_active_(!swapped_out), is_active_(!swapped_out),
is_pending_deletion_(false), is_pending_deletion_(false),
is_swapped_out_(swapped_out), is_swapped_out_(swapped_out),
......
...@@ -326,11 +326,6 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, ...@@ -326,11 +326,6 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost,
// currently using it. // currently using it.
int ref_count() { return frames_ref_count_; } int ref_count() { return frames_ref_count_; }
// TODO(avi): Move to RenderFrameHost once PageState is broken up into
// FrameStates.
int nav_entry_id() const { return nav_entry_id_; }
void set_nav_entry_id(int nav_entry_id) { nav_entry_id_ = nav_entry_id; }
// NOTE: Do not add functions that just send an IPC message that are called in // NOTE: Do not add functions that just send an IPC message that are called in
// one or two places. Have the caller send the IPC message directly (unless // one or two places. Have the caller send the IPC message directly (unless
// the caller places are in different platforms, in which case it's better // the caller places are in different platforms, in which case it's better
...@@ -439,11 +434,6 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, ...@@ -439,11 +434,6 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost,
// TODO(creis): Allocate this in WebContents/NavigationController instead. // TODO(creis): Allocate this in WebContents/NavigationController instead.
int32 page_id_; int32 page_id_;
// The unique ID of the latest NavigationEntry that this RenderViewHost is
// showing. TODO(avi): Move to RenderFrameHost once PageState is broken up
// into FrameStates.
int nav_entry_id_;
// Tracks whether this RenderViewHost is in an active state. False if the // Tracks whether this RenderViewHost is in an active state. False if the
// main frame is pending swap out, pending deletion, or swapped out, because // main frame is pending swap out, pending deletion, or swapped out, because
// it is not visible to the user in any of these cases. // it is not visible to the user in any of these cases.
......
...@@ -3890,7 +3890,7 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh, ...@@ -3890,7 +3890,7 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh,
return; return;
NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
rvhi->nav_entry_id()); static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
// TODO(creis): We can't properly update state for cross-process subframes // TODO(creis): We can't properly update state for cross-process subframes
...@@ -4074,10 +4074,8 @@ void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host, ...@@ -4074,10 +4074,8 @@ void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host,
NavigationEntryImpl* entry = controller_.GetEntryWithPageID( NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
render_frame_host->GetSiteInstance(), page_id); render_frame_host->GetSiteInstance(), page_id);
RenderViewHostImpl* rvhi =
static_cast<RenderViewHostImpl*>(render_frame_host->GetRenderViewHost());
NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
rvhi->nav_entry_id()); static_cast<RenderFrameHostImpl*>(render_frame_host)->nav_entry_id());
DCHECK_EQ(entry, new_entry); DCHECK_EQ(entry, new_entry);
// We can handle title updates when we don't have an entry in // We can handle title updates when we don't have an entry in
......
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