Index: content/browser/frame_host/frame_tree.h |
diff --git a/content/browser/frame_host/frame_tree.h b/content/browser/frame_host/frame_tree.h |
index 4a1d841c0f3e842609cdf3d31673bd32d655966f..64b4ba94ad690d5eaaaa1d12cf03febf1579551d 100644 |
--- a/content/browser/frame_host/frame_tree.h |
+++ b/content/browser/frame_host/frame_tree.h |
@@ -33,9 +33,6 @@ class RenderWidgetHostDelegate; |
// TODO(ajwong): Move NavigationController ownership to the main frame |
// FrameTreeNode. Possibly expose access to it from here. |
// |
-// TODO(ajwong): Currently this class only contains FrameTreeNodes for |
-// subframes if the --site-per-process flag is enabled. |
-// |
// This object is only used on the UI thread. |
class CONTENT_EXPORT FrameTree { |
public: |
@@ -59,38 +56,15 @@ class CONTENT_EXPORT FrameTree { |
// if |on_node| is just doing a search over the tree. |
void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
- // After the FrameTree is created, or after SwapMainFrame() has been called, |
- // the root node does not yet have a frame id. This is allocated by the |
- // renderer and is published to the browser process on the first navigation |
- // after a swap. These two functions are used to set the root node's frame |
- // id. |
- // |
- // TODO(ajwong): Remove these once RenderFrameHost's routing id replaces |
- // frame_id. |
- bool IsFirstNavigationAfterSwap() const; |
- void OnFirstNavigationAfterSwap(int main_frame_id); |
- |
// Frame tree manipulation routines. |
- // TODO(creis): These should take in RenderFrameHost routing IDs. |
- void AddFrame(int render_frame_host_id, |
- int64 parent_frame_tree_node_id, |
+ void AddFrame(RenderViewHostImpl* parent_render_view_host, |
+ int render_frame_host_id, |
+ int64 parent_frame_id, |
int64 frame_id, |
const std::string& frame_name); |
- void RemoveFrame(int64 parent_frame_id, int64 frame_id); |
- void SetFrameUrl(int64 frame_id, const GURL& url); |
- |
- // Resets the FrameTree and changes RenderFrameHost for the main frame. |
- // This destroys most of the frame tree but retains the root node so that |
- // navigation state may be kept on it between process swaps. Used to |
- // support bookkeeping for top-level navigations. |
- // |
- // If |main_frame| is NULL, reset tree to initially constructed state. |
- // |
- // TODO(ajwong): This function should not be given a |main_frame|. This is |
- // required currently because the RenderViewHost owns its main frame. When |
- // that relation is fixed, the FrameTree should be responsible for |
- // created/destroying the main frame on the swap. |
- void SwapMainFrame(RenderFrameHostImpl* main_frame); |
+ void RemoveFrame(int64 parent_frame_tree_node_id, |
+ int64 frame_tree_node_id); |
+ void SetFrameUrl(int64 frame_tree_node_id, const GURL& url); |
// Convenience accessor for the main frame's RenderFrameHostImpl. |
RenderFrameHostImpl* GetMainFrame() const; |
@@ -102,19 +76,25 @@ class CONTENT_EXPORT FrameTree { |
void SetFrameRemoveListener( |
const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); |
+ // Get the RenderViewHost needed for a new RenderFrameHost in the given |
+ // |site_instance|. Creates it if necessary and increments the refcount. |
+ // The RenderViewHost will have its Shutdown method called when all of the |
+ // RenderFrameHosts using it are deleted. |
+ RenderViewHostImpl* GetRenderViewHostForNewFrame(SiteInstance* site_instance, |
+ int routing_id, |
+ int main_frame_routing_id, |
+ bool swapped_out, |
+ bool hidden); |
+ |
FrameTreeNode* root() const { return root_.get(); } |
private: |
- // Returns the FrameTreeNode with the given renderer-specific |frame_id|. |
- // For internal use only. |
- // TODO(creis): Replace this with a version that takes in a routing ID. |
- FrameTreeNode* FindByFrameID(int64 frame_id); |
+ typedef base::hash_map<int, RenderViewHostImpl*> RenderViewHostMap; |
scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, |
const std::string& frame_name, |
- int render_frame_host_id, |
Navigator* navigator, |
- RenderProcessHost* render_process_host); |
+ RenderViewHostImpl* render_view_host); |
// These delegates are installed into all the RenderViewHosts and |
// RenderFrameHosts that we create. |
@@ -124,6 +104,11 @@ class CONTENT_EXPORT FrameTree { |
scoped_ptr<FrameTreeNode> root_; |
+ // Map of SiteInstance ID to RenderViewHost, which we can consult when |
+ // creating a new RenderFrameHost in this tree. RenderViewHosts are kept |
+ // alive as long as they have at least one RenderFrameHost using them. |
+ RenderViewHostMap render_view_host_map_; |
+ |
base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; |
DISALLOW_COPY_AND_ASSIGN(FrameTree); |