Index: content/browser/renderer_host/frame_tree.h |
diff --git a/content/browser/renderer_host/frame_tree.h b/content/browser/renderer_host/frame_tree.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ad7a97e04fd769f3c6941017214e0d7360a93061 |
--- /dev/null |
+++ b/content/browser/renderer_host/frame_tree.h |
@@ -0,0 +1,84 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ |
+#define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/browser/renderer_host/frame_tree_node.h" |
+#include "content/common/content_export.h" |
+ |
+namespace content { |
+ |
+class FrameTreeNode; |
+class RenderProcessHost; |
+ |
+// Represents the frame tree for a page. Used to manage RenderFrameHost during |
Charlie Reis
2013/09/11 22:25:04
FrameTree doesn't manage RFHs; FrameTreeNode does.
awong
2013/09/21 01:19:56
Done.
|
+// navigation. Eventually each node in this class will optionally contain a |
Charlie Reis
2013/09/11 22:25:04
This seems hard to understand unless you know our
awong
2013/09/21 01:19:56
Moved to TODO
|
+// NavigationController. The main frame node is guaranteed to have a |
Charlie Reis
2013/09/11 22:25:04
frame node -> FrameTreeNode (here and below)
(Too
awong
2013/09/21 01:19:56
Yep...rewrote the comment.
|
+// NavigationController. Because of this, the main frame node cannot change |
+// during navigation. Instead, we reset its children and navigation related |
+// state variables. |
+class CONTENT_EXPORT FrameTree { |
+ public: |
+ explicit FrameTree(); |
nasko
2013/09/11 22:26:24
Isn't explicit needed only for one argument constr
awong
2013/09/21 01:19:56
Done.
|
+ ~FrameTree(); |
+ |
+ // Indiates the that RenderFrameHost for the main frame needs to be changed. |
nasko
2013/09/11 22:26:24
nit: Indicates
awong
2013/09/21 01:19:56
Done.
|
+ // This effectively resets the frame tree but retains the root node so that |
+ // navigation state may be kept on it between process swaps. |
+ scoped_ptr<RenderFrameHostImpl> SwapMainFrame( |
Charlie Reis
2013/09/11 22:25:04
I'm not sure I understand why this is an operation
awong
2013/09/21 01:19:56
I think the name didn't match the semantics. Also
|
+ scoped_ptr<RenderFrameHostImpl> render_frame_host); |
+ |
+ // Returns the FrameTreeNode with the given |frame_id|. |
+ FrameTreeNode* FindByID(int64 frame_id); |
+ |
+ // Executes |on_node| on each node in the frame tree. If |on_node| returns |
+ // false, terminates the loop without continuing. |
+ 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. |
+ // 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 IsFirstNavigation() const; |
+ void OnFirstNavigation(int main_frame_id); |
Charlie Reis
2013/09/11 22:25:04
Which kind of frame ID are we talking about here,
awong
2013/09/21 01:19:56
It's the render-allocated frame_id. It's only rele
|
+ |
+ // 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); |
+ |
+ // Convenience accessor for the main frame's RenderFrameHostImpl. |
+ RenderFrameHostImpl* GetMainFrame() const; |
+ |
+ // Allows a client to listen for frame removal. |
+ void SetFrameRemoveListener( |
+ const base::Callback<void(int64)>& on_frame_removed); |
+ |
+ FrameTreeNode* GetRootForTesting() { return root_.get(); } |
+ |
+ private: |
+ scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, |
+ const std::string& frame_name, |
+ int render_frame_host_id, |
+ RenderProcessHost* render_process_host); |
+ |
+ scoped_ptr<FrameTreeNode> root_; |
+ |
+ base::Callback<void(int64)> on_frame_removed_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FrameTree); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ |