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

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

Issue 967383002: PlzNavigate: Avoid duplicate SiteInstance creation during navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests to check RFHM::ConvertToSiteInstance works as expected. Created 5 years, 9 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.h
diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h
index 89eeef69f9d549dc85a644eb8021a57176ce91d2..1a63e02f1b17bdebbb13d53eb04f552d76d7c173 100644
--- a/content/browser/frame_host/render_frame_host_manager.h
+++ b/content/browser/frame_host/render_frame_host_manager.h
@@ -423,6 +423,38 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest,
CreateCrossProcessSubframeProxies);
+ // PlzNavigate
+ enum RenderFrameHostToUse {
Charlie Reis 2015/04/02 21:23:25 This is dead code now, right? Sorry for missing t
carlosk 2015/04/03 16:11:19 Indeed. I forgot about it too. Removed.
+ INVALID,
+ REUSE_CURRENT,
+ NEW_SPECULATIVE,
+ REUSE_SPECULATIVE,
+ };
+
+ // Stores information regarding a SiteInstance targeted at a specific URL to
+ // allow for comparisons without having to actually create new instances. It
+ // can point to an existing one or store the details needed to create a new
+ // one.
+ struct SiteInstanceDescriptor {
+ explicit SiteInstanceDescriptor(content::SiteInstance* site_instance)
+ : existing_site_instance(site_instance),
+ new_is_related_to_current(false) {}
+
+ SiteInstanceDescriptor(GURL dest_url,
+ bool related_to_current,
+ BrowserContext* browser_context);
+
+ // Set with an existing SiteInstance to be reused.
+ content::SiteInstance* existing_site_instance;
+
+ // In case |existing_site_instance| is null, specify a new site URL.
+ GURL new_site_url;
+
+ // In case |existing_site_instance| is null, specify if the new site should
+ // be created in a new BrowsingInstance or not.
+ bool new_is_related_to_current;
+ };
+
// Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a
// FrameTreeNode's RenderFrameHostManager.
static bool ClearProxiesInSiteInstance(int32 site_instance_id,
@@ -471,29 +503,40 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
SiteInstance* GetSiteInstanceForNavigation(const GURL& dest_url,
SiteInstance* source_instance,
SiteInstance* dest_instance,
+ SiteInstance* candidate_instance,
ui::PageTransition transition,
bool dest_is_restore,
bool dest_is_view_source_mode);
- // Returns an appropriate SiteInstance object for the given |dest_url|,
- // possibly reusing the current SiteInstance. If --process-per-tab is used,
- // this is only called when ShouldSwapBrowsingInstancesForNavigation returns
- // true. |source_instance| is the SiteInstance of the frame that initiated the
+ // Returns a descriptor of the appropriate SiteInstance object for the given
+ // |dest_url|, possibly reusing the current, source or destination
+ // SiteInstance. The actual SiteInstance can then be obtained calling
+ // ConvertToSiteInstance with the descriptor.
+ //
+ // |source_instance| is the SiteInstance of the frame that initiated the
// navigation. |current_instance| is the SiteInstance of the frame that is
- // currently navigating. |dest_instance|, is a predetermined SiteInstance
- // that'll be used if not null.
+ // currently navigating. |dest_instance| is a predetermined SiteInstance that
+ // will be used if not null.
// For example, if you have a parent frame A, which has a child frame B, and
// A is trying to change the src attribute of B, this will cause a navigation
// where the source SiteInstance is A and B is the current SiteInstance.
+ //
// This is a helper function for GetSiteInstanceForNavigation.
- SiteInstance* GetSiteInstanceForURL(const GURL& dest_url,
- SiteInstance* source_instance,
- SiteInstance* current_instance,
- SiteInstance* dest_instance,
- ui::PageTransition transition,
- bool dest_is_restore,
- bool dest_is_view_source_mode,
- bool force_browsing_instance_swap);
+ SiteInstanceDescriptor DetermineSiteInstanceForURL(
+ const GURL& dest_url,
+ SiteInstance* source_instance,
+ SiteInstance* current_instance,
+ SiteInstance* dest_instance,
+ ui::PageTransition transition,
+ bool dest_is_restore,
+ bool dest_is_view_source_mode,
+ bool force_browsing_instance_swap);
+
+ // Converts a SiteInstanceDescriptor to the actual SiteInstance it describes.
+ // If a |candidate_instance| is provided (is not nullptr) and it matches the
+ // description, it is returned as is.
+ SiteInstance* ConvertToSiteInstance(const SiteInstanceDescriptor& descriptor,
+ SiteInstance* candidate_instance);
// Determines the appropriate url to use as the current url for SiteInstance
// selection.

Powered by Google App Engine
This is Rietveld 408576698