Chromium Code Reviews| 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 c40cac4db9e694ea8fe43b6cb7bbe78ca7336497..9bf58fd73f06bccbce868f46c2b1e41a74244932 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 |
| @@ -297,11 +298,16 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
| // Called when a renderer sets its opener to null. |
| void DidDisownOpener(RenderFrameHost* render_frame_host); |
| - // Helper method to create and initialize a RenderFrameHost. If |flags| |
| - // has the CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags |
| - // enum, it will initially be 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, int flags); |
| + // Creates and initializes a RenderFrameHost. If |flags| has the |
| + // CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags enum, it will |
| + // initially be 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> CreateRenderFrame(SiteInstance* instance, |
| + int opener_route_id, |
| + int flags, |
| + const WebUIImpl* web_ui, |
| + int* routing_id_ptr); |
| // Helper method to create and initialize a RenderFrameProxyHost and return |
| // its routing id. |
| @@ -359,11 +365,29 @@ 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(); |
| + |
| + // PlzNavigate |
| + // Returns the speculative RenderFrameHost, or NULL if there is no pending |
|
nasko
2014/11/25 00:19:11
nit: null
carlosk
2014/11/28 13:08:17
Done.
|
| + // one. |
| + RenderFrameHostImpl* speculative_render_frame_host() const { |
|
nasko
2014/11/25 00:19:11
This isn't needed to be public. The tests that use
carlosk
2014/11/28 13:08:17
Done.
|
| + return speculative_render_frame_host_.get(); |
| + } |
| + |
| private: |
| friend class RenderFrameHostManagerTest; |
| friend class TestWebContents; |
| @@ -401,6 +425,10 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
| const GURL& new_effective_url, |
| bool new_is_view_source_mode) const; |
| + // 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( |
| @@ -442,12 +470,29 @@ 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 CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
| + SiteInstance* new_instance); |
| + |
| // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| int view_routing_id, |
| 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 |
| @@ -467,13 +512,20 @@ 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); |
| + // Discards a RenderFrameHost that was never made active (for active ones |
| + // SwapOutOldFrame is used instead). |
| + void DiscardRenderFrameHost( |
| + scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| + |
| // Holds |render_frame_host| until it can be deleted when its swap out ACK |
| // arrives. |
| void MoveToPendingDeleteHosts( |
| @@ -580,6 +632,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). |
|
clamy
2014/11/25 16:50:57
Remove the not yet true mention. It is true by now
carlosk
2014/11/28 13:08:17
Done.
|
| + 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); |
| }; |