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

Unified Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1874543002: Inside of content, prefer SiteInstanceImpl to SiteInstance. Base URL: https://chromium.googlesource.com/chromium/src.git@site_instance_unittest
Patch Set: Created 4 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/frame_host/render_frame_host_manager.cc
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
index a24d736e005df4ab896dbd649d998c286bf3a08f..ae44d2f97533aab47b111ef4a95328b52a3c86f3 100644
--- a/content/browser/frame_host/render_frame_host_manager.cc
+++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -84,7 +84,7 @@ RenderFrameHostManager::~RenderFrameHostManager() {
SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>());
}
-void RenderFrameHostManager::Init(SiteInstance* site_instance,
+void RenderFrameHostManager::Init(SiteInstanceImpl* site_instance,
int32_t view_routing_id,
int32_t frame_routing_id,
int32_t widget_routing_id) {
@@ -564,7 +564,7 @@ void RenderFrameHostManager::CommitPendingIfNecessary(
void RenderFrameHostManager::DidChangeOpener(
int opener_routing_id,
- SiteInstance* source_site_instance) {
+ SiteInstanceImpl* source_site_instance) {
FrameTreeNode* opener = nullptr;
if (opener_routing_id != MSG_ROUTING_NONE) {
RenderFrameHostImpl* opener_rfhi = RenderFrameHostImpl::FromID(
@@ -614,7 +614,7 @@ void RenderFrameHostManager::CommitPendingSandboxFlags() {
// Notify all of the frame's proxies about updated sandbox flags, excluding
// the parent process since it already knows the latest flags.
- SiteInstance* parent_site_instance =
+ SiteInstanceImpl* parent_site_instance =
frame_tree_node_->parent()->current_frame_host()->GetSiteInstance();
for (const auto& pair : proxy_hosts_) {
if (pair.second->GetSiteInstance() != parent_site_instance) {
@@ -783,19 +783,21 @@ RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation(
const NavigationRequest& request) {
CHECK(IsBrowserSideNavigationEnabled());
- SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance();
+ SiteInstanceImpl* current_site_instance =
+ render_frame_host_->GetSiteInstance();
- SiteInstance* candidate_site_instance =
+ SiteInstanceImpl* candidate_site_instance =
speculative_render_frame_host_
? speculative_render_frame_host_->GetSiteInstance()
: nullptr;
- scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation(
- request.common_params().url, request.source_site_instance(),
- request.dest_site_instance(), candidate_site_instance,
- request.common_params().transition,
- request.restore_type() != NavigationEntryImpl::RESTORE_NONE,
- request.is_view_source());
+ scoped_refptr<SiteInstanceImpl> dest_site_instance =
+ GetSiteInstanceForNavigation(
+ request.common_params().url, request.source_site_instance(),
+ request.dest_site_instance(), candidate_site_instance,
+ request.common_params().transition,
+ request.restore_type() != NavigationEntryImpl::RESTORE_NONE,
+ request.is_view_source());
// The appropriate RenderFrameHost to commit the navigation.
RenderFrameHostImpl* navigation_rfh = nullptr;
@@ -1018,7 +1020,7 @@ void RenderFrameHostManager::ActiveFrameCountIsZero(
}
RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost(
- SiteInstance* site_instance,
+ SiteInstanceImpl* site_instance,
RenderViewHostImpl* rvh) {
int site_instance_id = site_instance->GetId();
CHECK(proxy_hosts_.find(site_instance_id) == proxy_hosts_.end())
@@ -1031,7 +1033,7 @@ RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost(
}
void RenderFrameHostManager::DeleteRenderFrameProxyHost(
- SiteInstance* site_instance) {
+ SiteInstanceImpl* site_instance) {
static_cast<SiteInstanceImpl*>(site_instance)->RemoveObserver(this);
proxy_hosts_.erase(site_instance->GetId());
}
@@ -1063,7 +1065,7 @@ bool RenderFrameHostManager::ShouldTransitionCrossSite() {
bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation(
const GURL& current_effective_url,
bool current_is_view_source_mode,
- SiteInstance* new_site_instance,
+ SiteInstanceImpl* new_site_instance,
const GURL& new_effective_url,
bool new_is_view_source_mode) const {
// A subframe must stay in the same BrowsingInstance as its parent.
@@ -1138,16 +1140,16 @@ bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation(
return false;
}
-scoped_refptr<SiteInstance>
+scoped_refptr<SiteInstanceImpl>
RenderFrameHostManager::GetSiteInstanceForNavigation(
const GURL& dest_url,
- SiteInstance* source_instance,
- SiteInstance* dest_instance,
- SiteInstance* candidate_instance,
+ SiteInstanceImpl* source_instance,
+ SiteInstanceImpl* dest_instance,
+ SiteInstanceImpl* candidate_instance,
ui::PageTransition transition,
bool dest_is_restore,
bool dest_is_view_source_mode) {
- SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
+ SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
// We do not currently swap processes for navigations in webview tag guests.
if (current_instance->GetSiteURL().SchemeIs(kGuestScheme))
@@ -1183,7 +1185,7 @@ RenderFrameHostManager::GetSiteInstanceForNavigation(
dest_is_restore, dest_is_view_source_mode, force_swap);
}
- scoped_refptr<SiteInstance> new_instance =
+ scoped_refptr<SiteInstanceImpl> new_instance =
ConvertToSiteInstance(new_instance_descriptor, candidate_instance);
// If |force_swap| is true, we must use a different SiteInstance than the
// current one. If we didn't, we would have two RenderFrameHosts in the same
@@ -1198,9 +1200,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigation(
RenderFrameHostManager::SiteInstanceDescriptor
RenderFrameHostManager::DetermineSiteInstanceForURL(
const GURL& dest_url,
- SiteInstance* source_instance,
- SiteInstance* current_instance,
- SiteInstance* dest_instance,
+ SiteInstanceImpl* source_instance,
+ SiteInstanceImpl* current_instance,
+ SiteInstanceImpl* dest_instance,
ui::PageTransition transition,
bool dest_is_restore,
bool dest_is_view_source_mode,
@@ -1441,9 +1443,9 @@ bool RenderFrameHostManager::IsRendererTransferNeededForNavigation(
return false;
}
-scoped_refptr<SiteInstance> RenderFrameHostManager::ConvertToSiteInstance(
+scoped_refptr<SiteInstanceImpl> RenderFrameHostManager::ConvertToSiteInstance(
const SiteInstanceDescriptor& descriptor,
- SiteInstance* candidate_instance) {
+ SiteInstanceImpl* candidate_instance) {
SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
// Note: If the |candidate_instance| matches the descriptor, it will already
@@ -1454,7 +1456,8 @@ scoped_refptr<SiteInstance> RenderFrameHostManager::ConvertToSiteInstance(
// Note: If the |candidate_instance| matches the descriptor,
// GetRelatedSiteInstance will return it.
if (descriptor.relation == SiteInstanceRelation::RELATED)
- return current_instance->GetRelatedSiteInstance(descriptor.new_site_url);
+ return current_instance->GetRelatedSiteInstanceImpl(
+ descriptor.new_site_url);
if (descriptor.relation == SiteInstanceRelation::RELATED_DEFAULT_SUBFRAME)
return current_instance->GetDefaultSubframeSiteInstance();
@@ -1468,7 +1471,7 @@ scoped_refptr<SiteInstance> RenderFrameHostManager::ConvertToSiteInstance(
}
// Otherwise return a newly created one.
- return SiteInstance::CreateForURL(
+ return SiteInstanceImpl::CreateForURL(
delegate_->GetControllerForRenderManager().GetBrowserContext(),
descriptor.new_site_url);
}
@@ -1519,8 +1522,8 @@ bool RenderFrameHostManager::IsCurrentlySameSite(RenderFrameHostImpl* candidate,
}
void RenderFrameHostManager::CreatePendingRenderFrameHost(
- SiteInstance* old_instance,
- SiteInstance* new_instance) {
+ SiteInstanceImpl* old_instance,
+ SiteInstanceImpl* new_instance) {
if (pending_render_frame_host_)
CancelPending();
@@ -1539,8 +1542,8 @@ void RenderFrameHostManager::CreatePendingRenderFrameHost(
}
void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost(
- SiteInstance* old_instance,
- SiteInstance* new_instance) {
+ SiteInstanceImpl* old_instance,
+ SiteInstanceImpl* new_instance) {
// Only create opener proxies if they are in the same BrowsingInstance.
if (new_instance->IsRelatedSiteInstance(old_instance)) {
CreateOpenerProxies(new_instance, frame_tree_node_);
@@ -1572,7 +1575,7 @@ void RenderFrameHostManager::CreateProxiesForNewNamedFrame() {
FrameTreeNode* opener = frame_tree_node_->opener();
if (!opener || !frame_tree_node_->IsMainFrame())
return;
- SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
+ SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
// Start from opener's parent. There's no need to create a proxy in the
// opener's SiteInstance, since new windows are always first opened in the
@@ -1587,7 +1590,7 @@ void RenderFrameHostManager::CreateProxiesForNewNamedFrame() {
}
scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost(
- SiteInstance* site_instance,
+ SiteInstanceImpl* site_instance,
int32_t view_routing_id,
int32_t frame_routing_id,
int32_t widget_routing_id,
@@ -1628,8 +1631,8 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost(
// PlzNavigate
bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost(
- SiteInstance* old_instance,
- SiteInstance* new_instance) {
+ SiteInstanceImpl* old_instance,
+ SiteInstanceImpl* new_instance) {
CHECK(new_instance);
CHECK_NE(old_instance, new_instance);
@@ -1649,7 +1652,7 @@ bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost(
}
scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
- SiteInstance* instance,
+ SiteInstanceImpl* instance,
bool hidden,
int* view_routing_id_ptr) {
int32_t widget_routing_id = MSG_ROUTING_NONE;
@@ -1726,7 +1729,7 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
return nullptr;
}
-int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) {
+int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstanceImpl* instance) {
// A RenderFrameProxyHost should never be created in the same SiteInstance as
// the current RFH.
CHECK(instance);
@@ -1776,7 +1779,7 @@ void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) {
void RenderFrameHostManager::EnsureRenderViewInitialized(
RenderViewHostImpl* render_view_host,
- SiteInstance* instance) {
+ SiteInstanceImpl* instance) {
DCHECK(frame_tree_node_->IsMainFrame());
if (render_view_host->IsRenderViewLive())
@@ -1792,7 +1795,7 @@ void RenderFrameHostManager::EnsureRenderViewInitialized(
}
void RenderFrameHostManager::CreateOuterDelegateProxy(
- SiteInstance* outer_contents_site_instance,
+ SiteInstanceImpl* outer_contents_site_instance,
RenderFrameHostImpl* render_frame_host) {
CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests());
RenderFrameProxyHost* proxy =
@@ -1850,7 +1853,7 @@ bool RenderFrameHostManager::InitRenderFrame(
if (render_frame_host->IsRenderFrameLive())
return true;
- SiteInstance* site_instance = render_frame_host->GetSiteInstance();
+ SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance();
int opener_routing_id = MSG_ROUTING_NONE;
if (frame_tree_node_->opener())
@@ -1930,7 +1933,7 @@ bool RenderFrameHostManager::InitRenderFrame(
base::debug::SetCrashKeyValue("initrf_parent_proxy_exists",
parent_proxy ? "yes" : "no");
- SiteInstance* parent_instance =
+ SiteInstanceImpl* parent_instance =
frame_tree_node_->parent()->current_frame_host()->GetSiteInstance();
base::debug::SetCrashKeyValue(
"initrf_parent_is_in_same_site_instance",
@@ -1951,7 +1954,7 @@ bool RenderFrameHostManager::InitRenderFrame(
// from the parent.
FrameTreeNode* root = frame_tree_node_->frame_tree()->root();
if (root != frame_tree_node_->parent()) {
- SiteInstance* root_instance =
+ SiteInstanceImpl* root_instance =
root->current_frame_host()->GetSiteInstance();
base::debug::SetCrashKeyValue(
"initrf_root_is_in_same_site_instance",
@@ -1987,7 +1990,7 @@ bool RenderFrameHostManager::InitRenderFrame(
}
int RenderFrameHostManager::GetRoutingIdForSiteInstance(
- SiteInstance* site_instance) {
+ SiteInstanceImpl* site_instance) {
if (render_frame_host_->GetSiteInstance() == site_instance)
return render_frame_host_->GetRoutingID();
@@ -2143,8 +2146,8 @@ void RenderFrameHostManager::CommitPending() {
RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate(
const GURL& dest_url,
- SiteInstance* source_instance,
- SiteInstance* dest_instance,
+ SiteInstanceImpl* source_instance,
+ SiteInstanceImpl* dest_instance,
ui::PageTransition transition,
bool dest_is_restore,
bool dest_is_view_source_mode,
@@ -2180,8 +2183,8 @@ RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate(
}
}
- SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
- scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation(
+ SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
+ scoped_refptr<SiteInstanceImpl> new_instance = GetSiteInstanceForNavigation(
dest_url, source_instance, dest_instance, nullptr, transition,
dest_is_restore, dest_is_view_source_mode);
@@ -2388,7 +2391,7 @@ bool RenderFrameHostManager::IsOnSwappedOutList(
}
RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost(
- SiteInstance* instance) const {
+ SiteInstance* instance) const {
RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
if (proxy)
return proxy->GetRenderViewHost();
@@ -2397,7 +2400,8 @@ RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost(
RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost(
SiteInstance* instance) const {
- auto it = proxy_hosts_.find(instance->GetId());
+ auto it =
+ proxy_hosts_.find(static_cast<SiteInstanceImpl*>(instance)->GetId());
if (it != proxy_hosts_.end())
return it->second.get();
return nullptr;
@@ -2450,7 +2454,7 @@ void RenderFrameHostManager::CollectOpenerFrameTrees(
}
void RenderFrameHostManager::CreateOpenerProxies(
- SiteInstance* instance,
+ SiteInstanceImpl* instance,
FrameTreeNode* skip_this_node) {
std::vector<FrameTree*> opener_frame_trees;
base::hash_set<FrameTreeNode*> nodes_with_back_links;
@@ -2492,7 +2496,7 @@ void RenderFrameHostManager::CreateOpenerProxies(
}
void RenderFrameHostManager::CreateOpenerProxiesForFrameTree(
- SiteInstance* instance,
+ SiteInstanceImpl* instance,
FrameTreeNode* skip_this_node) {
// Currently, this function is only called on main frames. It should
// actually work correctly for subframes as well, so if that need ever
@@ -2540,7 +2544,7 @@ void RenderFrameHostManager::CreateOpenerProxiesForFrameTree(
}
}
-int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
+int RenderFrameHostManager::GetOpenerRoutingID(SiteInstanceImpl* instance) {
if (!frame_tree_node_->opener())
return MSG_ROUTING_NONE;
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | content/browser/frame_host/render_frame_proxy_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698