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 7394628bcbf3136c133ebe367c0852818915106c..7adcbe904a998f96083d663ec7f0dae5aa7f241d 100644 |
--- a/content/browser/frame_host/render_frame_host_manager.h |
+++ b/content/browser/frame_host/render_frame_host_manager.h |
@@ -20,20 +20,20 @@ |
#include "content/public/common/referrer.h" |
#include "ui/base/page_transition_types.h" |
+struct FrameHostMsg_BeginNavigation_Params; |
struct FrameMsg_Navigate_Params; |
namespace content { |
class BrowserContext; |
class CrossProcessFrameConnector; |
class CrossSiteTransferringRequest; |
-class InterstitialPageImpl; |
class FrameTreeNode; |
+class InterstitialPageImpl; |
class NavigationControllerImpl; |
class NavigationEntry; |
class NavigationEntryImpl; |
class RenderFrameHost; |
class RenderFrameHostDelegate; |
-class RenderFrameHost; |
class RenderFrameHostImpl; |
class RenderFrameHostManagerTest; |
class RenderFrameProxyHost; |
@@ -43,6 +43,7 @@ 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 |
@@ -231,10 +232,6 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
pending_and_current_web_ui_.get(); |
} |
- // Sets the pending Web UI for the pending navigation, ensuring that the |
- // bindings are appropriate compared to |bindings|. |
- void SetPendingWebUI(const GURL& url, int bindings); |
- |
// Called when we want to instruct the renderer to navigate to the given |
// navigation entry. It may create a new RenderFrameHost or re-use an existing |
// one. The RenderFrameHost to navigate will be returned. Returns NULL if one |
@@ -294,17 +291,19 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
// Called when a renderer's frame navigates. |
void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); |
+ // PlzNavigate |
+ // Cleans up ongoing navigation data. |
+ void CancelNavigation(); |
clamy
2014/11/19 15:03:29
nit: place this function with the other PlzNavigat
carlosk
2014/11/19 17:24:29
Done.
carlosk
2014/11/21 14:36:34
Done.
|
+ |
// Called when a renderer sets its opener to null. |
void DidDisownOpener(RenderFrameHost* render_frame_host); |
- // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
- // is true, it will be initially placed on the swapped out hosts list. |
- // Returns the routing id of the *view* associated with the frame. |
- int CreateRenderFrame(SiteInstance* instance, |
- int opener_route_id, |
- bool swapped_out, |
- bool for_main_frame_navigation, |
- bool hidden); |
+ // Creates and initializes a RenderFrameHost that is placed on the swapped out |
+ // hosts list and hidden. Returns the routing id of the *view* associated |
+ // with the frame. |
+ int CreateSwappedOutHiddenRenderFrame(SiteInstance* instance, |
+ int opener_route_id, |
+ bool for_main_frame_navigation); |
// Helper method to create and initialize a RenderFrameProxyHost and return |
// its routing id. |
@@ -362,11 +361,25 @@ 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 |
+ // Returns the speculative RenderFrameHost, or NULL if there is no pending |
+ // one. |
+ RenderFrameHostImpl* speculative_render_frame_host() const { |
+ return speculative_render_frame_host_.get(); |
+ } |
+ |
private: |
friend class RenderFrameHostManagerTest; |
friend class TestWebContents; |
@@ -404,6 +417,14 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
const GURL& new_effective_url, |
bool new_is_view_source_mode) const; |
+ // Sets the pending Web UI for the pending navigation, ensuring that the |
+ // bindings are appropriate compared to |bindings|. |
+ void SetPendingWebUI(const GURL& url, int bindings); |
+ |
+ // Creates a new Web UI, ensuring that the bindings are appropriate compared |
+ // to |bindings|. The caller is responsible for the instance ownership. |
+ WebUIImpl* CreateWebUI(const GURL& url, int bindings); |
+ |
// Returns true if it is safe to reuse the current WebUI when navigating from |
// |current_entry| to |new_url|. |
bool ShouldReuseWebUI( |
@@ -423,14 +444,13 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
// this is only called when ShouldSwapBrowsingInstancesForNavigation returns |
// true. |dest_instance| will be used if it is not null. |
// This is a helper function for GetSiteInstanceForNavigation. |
- SiteInstance* GetSiteInstanceForURL( |
- const GURL& dest_url, |
- SiteInstance* dest_instance, |
- ui::PageTransition dest_transition, |
- bool dest_is_restore, |
- bool dest_is_view_source_mode, |
- SiteInstance* current_instance, |
- bool force_browsing_instance_swap); |
+ SiteInstance* GetSiteInstanceForURL(const GURL& dest_url, |
+ SiteInstance* dest_instance, |
+ ui::PageTransition dest_transition, |
+ bool dest_is_restore, |
+ bool dest_is_view_source_mode, |
+ SiteInstance* current_instance, |
+ bool force_browsing_instance_swap); |
// Determines the appropriate url to use as the current url for SiteInstance |
// selection. |
@@ -445,6 +465,26 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
SiteInstance* new_instance, |
bool is_main_frame); |
+ // Ensure that we have created RFHs for the new RFH's opener chain if |
+ // we are staying in the same BrowsingInstance. This allows the new RFH |
+ // to send cross-process script calls to its opener(s). Returns the opener |
+ // route ID to be used for the new RenderView to be created. |
+ int GetOpenerRouteIDForNewRenderView(SiteInstance* old_instance, |
+ SiteInstance* new_instance); |
+ |
+ // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
+ // is true, it will be initially placed on the swapped out hosts list. |
+ // If |routing_id_ptr| is not NULL it will be set to the routing id of the |
+ // *view* associated with the frame. |
+ scoped_ptr<RenderFrameHostImpl> CreateRenderFrameInternal( |
+ SiteInstance* instance, |
+ int opener_route_id, |
+ bool swapped_out, |
+ bool for_main_frame_navigation, |
+ bool hidden, |
+ const WebUIImpl* web_ui, |
+ int* routing_id_ptr); |
+ |
// Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
int view_routing_id, |
@@ -452,6 +492,20 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
bool swapped_out, |
bool hidden); |
+ // 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); |
+ |
+ // PlzNavigate |
+ // Cleans up the date related to the speculative RenderFrameHost. |
+ void CleanUpSpeculativeRenderFrameHost(); |
+ |
// 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 |
@@ -471,13 +525,21 @@ 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. |
- void CommitPending(); |
+ // With PlzNavigate enabled, |use_speculative_rfh| can be set to true which |
+ // will cause the speculative RenderFrameHost to be the active one. |
+ void CommitPending(bool use_speculative_rfh); |
// Runs the unload handler in the old RenderFrameHost, after the new |
// RenderFrameHost has committed. |old_render_frame_host| will either be |
// deleted or put on the pending delete list during this call. |
void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
+ // Called to properly discard a created RenderFrameHost that was never made |
+ // active (for active ones SwapOutOldFrame is used instead). It can be swapped |
+ // out or fully destroyed. |
+ void RecycleRenderFrameHost( |
+ scoped_ptr<RenderFrameHostImpl> render_frame_host); |
+ |
// Holds |render_frame_host| until it can be deleted when its swap out ACK |
// arrives. |
void MoveToPendingDeleteHosts( |
@@ -584,6 +646,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. |
+ // Might be discarded later on if the final URL's SiteInstance doesn't match |
+ // what was assumed in the beginning. |
+ // Note: speculative RenderFrameHost is only used for PlzNavigate and pending |
+ // only for the regular navigation (not yet true, but will be). |
+ 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_; |
nasko
2014/11/19 01:00:24
Can we avoid adding yet more state?
carlosk
2014/11/19 17:24:29
As WebUI instances are held with scoped_ptr I can'
|
+ |
DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
}; |