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

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

Issue 701953006: PlzNavigate: Speculatively spawns a renderer process for navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-applied full CL changes, addressed comments, rebased, added tests and fixes. Created 6 years, 1 month 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 ae8d9f9ddc4ff6cd18c405da388ebe0e6334e09a..4ad245d7d3e063824bf951c007caafad64b40190 100644
--- a/content/browser/frame_host/render_frame_host_manager.h
+++ b/content/browser/frame_host/render_frame_host_manager.h
@@ -20,6 +20,7 @@
#include "content/public/common/referrer.h"
#include "ui/base/page_transition_types.h"
+struct FrameHostMsg_BeginNavigation_Params;
struct FrameMsg_Navigate_Params;
namespace content {
@@ -34,14 +35,13 @@ class NavigationEntryImpl;
class RenderFrameHost;
class RenderFrameHostDelegate;
class RenderFrameHostImpl;
-class RenderFrameHostManagerTest;
class RenderFrameProxyHost;
class RenderViewHost;
class RenderViewHostImpl;
class RenderWidgetHostDelegate;
class RenderWidgetHostView;
-class TestWebContents;
class WebUIImpl;
+struct CommonNavigationParams;
// Manages RenderFrameHosts for a FrameTreeNode. It maintains a
// current_frame_host() which is the content currently visible to the user. When
@@ -366,12 +366,24 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found.
int GetRoutingIdForSiteInstance(SiteInstance* site_instance);
- // PlzNavigate: Called when a navigation is ready to commit, to select the
- // renderer that will commit it.
+ // PlzNavigate
+ // Notifies the RFHM that a navigation is about to begin so that it can
+ // speculatively spawn a new renderer process if needed.
+ void BeginNavigation(const FrameHostMsg_BeginNavigation_Params& params,
+ const CommonNavigationParams& common_params);
+
+ // PlzNavigate
+ // Called when a navigation is ready to commit, to select the renderer that
+ // will commit it.
RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url,
ui::PageTransition transition);
+ // PlzNavigate
+ // Cancels any ongoing navigation.
+ void CleanUpNavigation();
+
private:
+ friend class NavigatorTestWithBrowserSideNavigation;
friend class RenderFrameHostManagerTest;
friend class TestWebContents;
@@ -466,6 +478,16 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
int frame_routing_id,
int flags);
+ // PlzNavigate
+ // Creates a new RenderFrameHost and does all required supporting work for the
+ // speculative creation of a new renderer for an ongoing navigation request.
+ // This RenderFrameHost might be destroyed later if the final navigation
+ // destination doesn't match the initial one.
+ bool CreateSpeculativeRenderFrameHost(const GURL& url,
+ SiteInstance* old_instance,
+ SiteInstance* new_instance,
+ int bindings);
+
// Sets up the necessary state for a new RenderViewHost with the given opener,
// if necessary. It creates a RenderFrameProxy in the target renderer process
// with the given |proxy_routing_id|, which is used to route IPC messages when
@@ -485,6 +507,8 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
// doesn't require the pending render_frame_host_ pointer to be non-NULL,
// since there could be Web UI switching as well. Call this for every commit.
+ // If PlzNavigate is enabled the method will set the speculative
+ // RenderFrameHost to be the active one instead of the pending.
void CommitPending();
// Runs the unload handler in the old RenderFrameHost, after the new
@@ -531,6 +555,13 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// for the given |instance|.
void DeleteRenderFrameProxyHost(SiteInstance* instance);
+ // PlzNavigate
+ // Returns the speculative RenderFrameHost or nullptr if there is no pending
+ // one.
+ RenderFrameHostImpl* speculative_render_frame_host() const {
+ return speculative_render_frame_host_.get();
+ }
+
// For use in creating RenderFrameHosts.
FrameTreeNode* frame_tree_node_;
@@ -602,6 +633,21 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
+ // PlzNavigate
+ // Members to store the speculative RFH created upon starting a navigation
+ // allowing the creation of the renderer process as early as possible.
+ // The created instance might be discarded later on if the final URL's
+ // SiteInstance isn't compatible with what was used to create it.
+ // Note: speculative RenderFrameHost is only used for PlzNavigate and the
+ // pending one only for the regular navigation.
+ scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_;
+ scoped_ptr<WebUIImpl> speculative_web_ui_;
+
+ // PlzNavigate
+ // If true at navigation commit time the current WebUI will be kept instead of
+ // creating a new one.
+ bool should_reuse_web_ui_;
+
DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
};

Powered by Google App Engine
This is Rietveld 408576698