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

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

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | content/browser/frame_host/frame_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f9bf80970a618366509b7bb7e70efffa8da544a1..5a0ffbf5821b09ba009cf8f8779e438f2b5344dd 100644
--- a/content/browser/frame_host/frame_tree.h
+++ b/content/browser/frame_host/frame_tree.h
@@ -35,7 +35,13 @@ class RenderViewHostImpl;
// This object is only used on the UI thread.
class CONTENT_EXPORT FrameTree {
public:
- FrameTree();
+ // A set of delegates are remembered here so that we can create
+ // RenderFrameHostManagers (and so that those can create RVHs and RFHs).
+ // TODO(creis): This set of delegates will change as we create a Navigator
+ // interface.
+ FrameTree(RenderViewHostDelegate* render_view_delegate,
+ RenderWidgetHostDelegate* render_widget_delegate,
+ RenderViewHostManager::Delegate* manager_delegate);
~FrameTree();
// Returns the FrameTreeNode with the given |frame_id|.
@@ -46,35 +52,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.
- void AddFrame(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 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_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;
@@ -83,16 +69,50 @@ class CONTENT_EXPORT FrameTree {
void SetFrameRemoveListener(
const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed);
- FrameTreeNode* GetRootForTesting() { return root_.get(); }
+ // 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:
+ typedef base::hash_map<int, RenderViewHostImpl*> RenderViewHostMap;
+
+ // The next available FrameTreeNode ID.
+ static int64 next_frame_tree_node_id_;
+
scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id,
const std::string& frame_name,
int render_frame_host_id,
- RenderProcessHost* render_process_host);
+ RenderViewHostImpl* render_view_host);
+
+ // Generate a browser-wide unique ID for a new FrameTreeNode.
+ int64 GetNextFrameTreeNodeID();
+
+ // These delegates are installed into all the RenderViewHosts and
+ // RenderFrameHosts that we create.
+ RenderViewHostDelegate* render_view_delegate_;
+ RenderWidgetHostDelegate* render_widget_delegate_;
+ RenderViewHostManager::Delegate* manager_delegate_;
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_;
+
+ // Because of the complex shutdown path for RenderViewHosts, we also maintain
+ // the refcount for them in this class. This is a map from RenderViewHost
+ // routing ID to refcount.
+ base::hash_map<int, int> rvh_refcounts_;
+
base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_;
DISALLOW_COPY_AND_ASSIGN(FrameTree);
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | content/browser/frame_host/frame_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698