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 94a4998b62f492d944110a84fa2545524871928b..0360bd0b192387e1b817e073593242d2ba9227e4 100644 |
--- a/content/browser/frame_host/render_frame_host_manager.h |
+++ b/content/browser/frame_host/render_frame_host_manager.h |
@@ -20,10 +20,12 @@ |
namespace content { |
class BrowserContext; |
class InterstitialPageImpl; |
+class FrameTreeNode; |
class NavigationControllerImpl; |
class NavigationEntry; |
class NavigationEntryImpl; |
class RenderFrameHostDelegate; |
+class RenderFrameHostImpl; |
class RenderFrameHostManagerTest; |
class RenderViewHost; |
class RenderViewHostImpl; |
@@ -114,6 +116,7 @@ class CONTENT_EXPORT RenderFrameHostManager |
// |
// You must call Init() before using this class. |
RenderFrameHostManager( |
+ FrameTreeNode* frame_tree_node, |
RenderFrameHostDelegate* render_frame_delegate, |
RenderViewHostDelegate* render_view_delegate, |
RenderWidgetHostDelegate* render_widget_delegate, |
@@ -123,21 +126,31 @@ class CONTENT_EXPORT RenderFrameHostManager |
// For arguments, see WebContentsImpl constructor. |
void Init(BrowserContext* browser_context, |
SiteInstance* site_instance, |
- int routing_id, |
- int main_frame_routing_id); |
+ int view_routing_id, |
+ int frame_routing_id); |
- // Returns the currently active RenderViewHost. |
+ // Returns the currently active RenderFrameHost. |
// |
// This will be non-NULL between Init() and Shutdown(). You may want to NULL |
// check it in many cases, however. Windows can send us messages during the |
// destruction process after it has been shut down. |
+ RenderFrameHostImpl* current_frame_host() const { |
+ return render_frame_host_; |
+ } |
+ |
+ // TODO(creis): Remove this when we no longer use RVH for navigation. |
RenderViewHostImpl* current_host() const; |
// Returns the view associated with the current RenderViewHost, or NULL if |
// there is no current one. |
RenderWidgetHostView* GetRenderWidgetHostView() const; |
- // Returns the pending render view host, or NULL if there is no pending one. |
+ // Returns the pending RenderFrameHost, or NULL if there is no pending one. |
+ RenderFrameHostImpl* pending_frame_host() const { |
+ return pending_render_frame_host_; |
+ } |
+ |
+ // TODO(creis): Remove this when we no longer use RVH for navigation. |
RenderViewHostImpl* pending_render_view_host() const; |
// Returns the current committed Web UI or NULL if none applies. |
@@ -183,13 +196,13 @@ class CONTENT_EXPORT RenderFrameHostManager |
// Called when a renderer sets its opener to null. |
void DidDisownOpener(RenderViewHost* render_view_host); |
- // Helper method to create a RenderViewHost. If |swapped_out| is true, it |
- // will be initially placed on the swapped out hosts list. Otherwise, it |
- // will be used for a pending cross-site navigation. |
- int CreateRenderView(SiteInstance* instance, |
- int opener_route_id, |
- bool swapped_out, |
- bool hidden); |
+ // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
+ // is true, it will be initially placed on the swapped out hosts list. |
+ // Otherwise, it will be used for a pending cross-site navigation. |
+ int CreateRenderFrame(SiteInstance* instance, |
+ int opener_route_id, |
+ bool swapped_out, |
+ bool hidden); |
// Called when a provisional load on the given renderer is aborted. |
void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); |
@@ -236,12 +249,16 @@ class CONTENT_EXPORT RenderFrameHostManager |
// Called when a RenderViewHost is about to be deleted. |
void RenderViewDeleted(RenderViewHost* rvh); |
- // Returns whether the given RenderViewHost is on the list of swapped out |
- // RenderViewHosts. |
- bool IsOnSwappedOutList(RenderViewHost* rvh) const; |
+ // Returns whether the given RenderFrameHost (or its associated |
+ // RenderViewHost) is on the list of swapped out RenderFrameHosts. |
+ bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; |
+ bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; |
- // Returns the swapped out RenderViewHost for the given SiteInstance, if any. |
- RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); |
+ // Returns the swapped out RenderViewHost or RenderFrameHost for the given |
+ // SiteInstance, if any. |
+ RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; |
+ RenderFrameHostImpl* GetSwappedOutRenderFrameHost( |
+ SiteInstance* instance) const; |
// Runs the unload handler in the current page, when we know that a pending |
// cross-process navigation is going to commit. We may initiate a transfer |
@@ -253,7 +270,7 @@ class CONTENT_EXPORT RenderFrameHostManager |
friend class TestWebContents; |
// Tracks information about a navigation while a cross-process transition is |
- // in progress, in case we need to transfer it to a new RenderViewHost. |
+ // in progress, in case we need to transfer it to a new RenderFrameHost. |
struct PendingNavigationParams { |
PendingNavigationParams(); |
PendingNavigationParams(const GlobalRequestID& global_request_id, |
@@ -295,6 +312,11 @@ class CONTENT_EXPORT RenderFrameHostManager |
bool should_replace_current_entry; |
}; |
+ // Used with FrameTree::ForEach to erase inactive RenderFrameHosts from a |
+ // FrameTreeNode's RenderFrameHostManager. |
+ static bool ClearSwappedOutRFHsInSiteInstance(int32 site_instance_id, |
+ FrameTreeNode* node); |
+ |
// Returns whether this tab should transition to a new renderer for |
// cross-site URLs. Enabled unless we see the --process-per-tab command line |
// switch. Can be overridden in unit tests. |
@@ -325,60 +347,76 @@ class CONTENT_EXPORT RenderFrameHostManager |
SiteInstance* current_instance, |
bool force_browsing_instance_swap); |
- // Sets up the necessary state for a new RenderViewHost with the given opener. |
+ // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
+ RenderFrameHostImpl* CreateRenderFrameHost(SiteInstance* instance, |
+ int view_routing_id, |
+ int frame_routing_id, |
+ bool swapped_out, |
+ bool hidden); |
+ |
+ // Sets up the necessary state for a new RenderViewHost with the given opener, |
+ // if necessary. Returns early if the RenderViewHost has already been |
+ // initialized for another RenderFrameHost. |
+ // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
+ // be for the RenderFrame, since frames can have openers. |
bool InitRenderView(RenderViewHost* render_view_host, int opener_route_id); |
- // Sets the pending RenderViewHost/WebUI to be the active one. Note that this |
- // doesn't require the pending render_view_host_ pointer to be non-NULL, since |
- // there could be Web UI switching as well. Call this for every commit. |
+ // 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(); |
- // Shutdown all RenderViewHosts in a SiteInstance. This is called |
- // to shutdown views when all the views in a SiteInstance are |
- // confirmed to be swapped out. |
- void ShutdownRenderViewHostsInSiteInstance(int32 site_instance_id); |
+ // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown |
+ // frames when all the frames in a SiteInstance are confirmed to be swapped |
+ // out. |
+ void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id); |
// Helper method to terminate the pending RenderViewHost. |
void CancelPending(); |
- RenderViewHostImpl* UpdateRendererStateForNavigate( |
+ RenderFrameHostImpl* UpdateRendererStateForNavigate( |
const NavigationEntryImpl& entry); |
// Called when a renderer process is starting to close. We should not |
- // schedule new navigations in its swapped out RenderViewHosts after this. |
+ // schedule new navigations in its swapped out RenderFrameHosts after this. |
void RendererProcessClosing(RenderProcessHost* render_process_host); |
+ // For use in creating RenderFrameHosts. |
+ FrameTreeNode* frame_tree_node_; |
+ |
// Our delegate, not owned by us. Guaranteed non-NULL. |
Delegate* delegate_; |
- // Whether a navigation requiring different RenderView's is pending. This is |
- // either cross-site request is (in the new process model), or when required |
- // for the view type (like view source versus not). |
+ // Whether a navigation requiring different RenderFrameHosts is pending. This |
+ // is either for cross-site requests or when required for the process type |
+ // (like WebUI). |
bool cross_navigation_pending_; |
- // Implemented by the owner of this class, these delegates are installed into |
- // all the RenderViewHosts that we create. |
+ // Implemented by the owner of this class. These delegates are installed into |
+ // all the RenderFrameHosts that we create. |
RenderFrameHostDelegate* render_frame_delegate_; |
RenderViewHostDelegate* render_view_delegate_; |
RenderWidgetHostDelegate* render_widget_delegate_; |
- // Our RenderView host and its associated Web UI (if any, will be NULL for |
- // non-DOM-UI pages). This object is responsible for all communication with |
- // a child RenderView instance. |
- RenderViewHostImpl* render_view_host_; |
+ // Our RenderFrameHost and its associated Web UI (if any, will be NULL for |
+ // non-WebUI pages). This object is responsible for all communication with |
+ // a child RenderFrame instance. |
+ // For now, RenderFrameHost keeps a RenderViewHost in its SiteInstance alive. |
+ // Eventually, RenderViewHost will be replaced with a page context. |
+ RenderFrameHostImpl* render_frame_host_; |
scoped_ptr<WebUIImpl> web_ui_; |
- // A RenderViewHost used to load a cross-site page. This remains hidden |
+ // A RenderFrameHost used to load a cross-site page. This remains hidden |
// while a cross-site request is pending until it calls DidNavigate. It may |
// have an associated Web UI, in which case the Web UI pointer will be non- |
// NULL. |
// |
// The |pending_web_ui_| may be non-NULL even when the |
- // |pending_render_view_host_| is NULL. This will happen when we're |
- // transitioning between two Web UI pages: the RVH won't be swapped, so the |
+ // |pending_render_frame_host_| is NULL. This will happen when we're |
+ // transitioning between two Web UI pages: the RFH won't be swapped, so the |
// pending pointer will be unused, but there will be a pending Web UI |
// associated with the navigation. |
- RenderViewHostImpl* pending_render_view_host_; |
+ RenderFrameHostImpl* pending_render_frame_host_; |
// Tracks information about any current pending cross-process navigation. |
scoped_ptr<PendingNavigationParams> pending_nav_params_; |
@@ -390,10 +428,10 @@ class CONTENT_EXPORT RenderFrameHostManager |
scoped_ptr<WebUIImpl> pending_web_ui_; |
base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
- // A map of site instance ID to swapped out RenderViewHosts. This may include |
- // pending_render_view_host_ for navigations to existing entries. |
- typedef base::hash_map<int32, RenderViewHostImpl*> RenderViewHostMap; |
- RenderViewHostMap swapped_out_hosts_; |
+ // A map of site instance ID to swapped out RenderFrameHosts. This may |
+ // include pending_render_frame_host_ for navigations to existing entries. |
+ typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap; |
+ RenderFrameHostMap swapped_out_hosts_; |
// The intersitial page currently shown if any, not own by this class |
// (the InterstitialPage is self-owned, it deletes itself when hidden). |