Commit 7f782752 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Check if frame has committed any navigation in ShouldProactivelySwapBrowsingInstance

We shouldn't proctively swap BrowsingInstances if the current frame has
not committed any navigation yet.
See: https://chromium-review.googlesource.com/c/chromium/src/+/2210174/16/content/browser/frame_host/render_document_host_user_data_browsertest.cc#305

Bug: 977562
Change-Id: If228976b79d6fb0e8cc99492a50c5acb65bef73e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340361
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795723}
parent 9aadacba
...@@ -1311,6 +1311,11 @@ RenderFrameHostManager::ShouldProactivelySwapBrowsingInstance( ...@@ -1311,6 +1311,11 @@ RenderFrameHostManager::ShouldProactivelySwapBrowsingInstance(
if (!render_frame_host_->frame_tree_node()->IsMainFrame()) if (!render_frame_host_->frame_tree_node()->IsMainFrame())
return ShouldSwapBrowsingInstance::kNo_NotMainFrame; return ShouldSwapBrowsingInstance::kNo_NotMainFrame;
// If the frame has not committed any navigation yet, we should not try to do
// a proactive swap.
if (!render_frame_host_->has_committed_any_navigation())
return ShouldSwapBrowsingInstance::kNo_HasNotComittedAnyNavigation;
// Skip cases when there are other windows that might script this one. // Skip cases when there are other windows that might script this one.
SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
if (current_instance->GetRelatedActiveContentsCount() > 1u) if (current_instance->GetRelatedActiveContentsCount() > 1u)
......
...@@ -31,8 +31,9 @@ enum class ShouldSwapBrowsingInstance { ...@@ -31,8 +31,9 @@ enum class ShouldSwapBrowsingInstance {
kNo_WillReplaceEntry = 16, kNo_WillReplaceEntry = 16,
kNo_Reload = 17, kNo_Reload = 17,
kNo_Guest = 18, kNo_Guest = 18,
kNo_HasNotComittedAnyNavigation = 19,
kMaxValue = kNo_Guest kMaxValue = kNo_HasNotComittedAnyNavigation
}; };
} // namespace content } // namespace content
......
...@@ -5705,6 +5705,7 @@ Unknown properties are collapsed to zero. --> ...@@ -5705,6 +5705,7 @@ Unknown properties are collapsed to zero. -->
<int value="16" label="The current history entry will get replaced"/> <int value="16" label="The current history entry will get replaced"/>
<int value="17" label="Reload"/> <int value="17" label="Reload"/>
<int value="18" label="Guest"/> <int value="18" label="Guest"/>
<int value="19" label="The frame has not comitted any navigations yet"/>
</enum> </enum>
<enum name="BackForwardCacheDisabledForRenderFrameHostReason"> <enum name="BackForwardCacheDisabledForRenderFrameHostReason">
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