Commit b9f1aa01 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Reuse process on history navigations between same-site cross-BI pages

See crbug.com/1096135 for context. When doing same-site navigations, we
might do a proactive BrowsingInstance swap, but we will reuse the
renderer process whenever we can. On history navigations between pages
that are same-site but have different BrowsingInstances (not only on
cases that are caused by proactive BI swap), we should try to reuse the
renderer process.

Bug: 1096135
Change-Id: I58f72bedecbbf94e4e05218bb9c15970a502d8a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2282553
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792195}
parent 2dd1098a
...@@ -1538,6 +1538,26 @@ RenderFrameHostManager::GetSiteInstanceForNavigation( ...@@ -1538,6 +1538,26 @@ RenderFrameHostManager::GetSiteInstanceForNavigation(
new_instance_impl->ReuseCurrentProcessIfPossible( new_instance_impl->ReuseCurrentProcessIfPossible(
current_instance->GetProcess()); current_instance->GetProcess());
} }
// If this is a same-site history navigation with different BrowsingInstances,
// the original navigation might have done a proactive BrowsingInstance swap,
// which means we should try to reuse the current process (because we did too
// on the original navigation).
bool is_history_navigation = !!dest_instance;
bool swapped_browsing_instance =
!new_instance->IsRelatedSiteInstance(current_instance);
if (IsProactivelySwapBrowsingInstanceOnSameSiteNavigationEnabled() &&
is_history_navigation && swapped_browsing_instance &&
frame_tree_node_->IsMainFrame() &&
IsCurrentlySameSite(
static_cast<RenderFrameHostImpl*>(render_frame_host_.get()),
dest_url)) {
// TODO(crbug.com/1107269): DCHECK for frame_tree_node_->IsMainFrame() once
// we can guarantee all cross-BrowsingInstance history navigations only
// happen on main frames.
new_instance_impl->ReuseCurrentProcessIfPossible(
current_instance->GetProcess());
}
return new_instance; return new_instance;
} }
......
...@@ -359,6 +359,9 @@ void SiteInstanceImpl::ReuseCurrentProcessIfPossible( ...@@ -359,6 +359,9 @@ void SiteInstanceImpl::ReuseCurrentProcessIfPossible(
current_process, GetIsolationContext(), site_info_, IsGuest())) { current_process, GetIsolationContext(), site_info_, IsGuest())) {
return; return;
} }
// TODO(crbug.com/1055779 ): Don't try to reuse process if either of the
// SiteInstances are cross-origin isolated (uses COOP/COEP).
SetProcessInternal(current_process); SetProcessInternal(current_process);
} }
......
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