Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // | 31 // |
| 32 // TODO(ajwong): Currently this class only contains FrameTreeNodes for | 32 // TODO(ajwong): Currently this class only contains FrameTreeNodes for |
| 33 // subframes if the --site-per-process flag is enabled. | 33 // subframes if the --site-per-process flag is enabled. |
| 34 // | 34 // |
| 35 // This object is only used on the UI thread. | 35 // This object is only used on the UI thread. |
| 36 class CONTENT_EXPORT FrameTree { | 36 class CONTENT_EXPORT FrameTree { |
| 37 public: | 37 public: |
| 38 FrameTree(); | 38 FrameTree(); |
| 39 ~FrameTree(); | 39 ~FrameTree(); |
| 40 | 40 |
| 41 // Returns the FrameTreeNode with the given |frame_id|. | 41 // Returns the FrameTreeNode with the given |frame_tree_node_id|. |
| 42 FrameTreeNode* FindByID(int64 frame_id); | 42 FrameTreeNode* FindByID(int64 frame_tree_node_id); |
| 43 | 43 |
| 44 // Executes |on_node| on each node in the frame tree. If |on_node| returns | 44 // Executes |on_node| on each node in the frame tree. If |on_node| returns |
| 45 // false, terminates the iteration immediately. Returning false is useful | 45 // false, terminates the iteration immediately. Returning false is useful |
| 46 // if |on_node| is just doing a search over the tree. | 46 // if |on_node| is just doing a search over the tree. |
| 47 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | 47 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
| 48 | 48 |
| 49 // After the FrameTree is created, or after SwapMainFrame() has been called, | 49 // After the FrameTree is created, or after SwapMainFrame() has been called, |
| 50 // the root node does not yet have a frame id. This is allocated by the | 50 // the root node does not yet have a frame id. This is allocated by the |
| 51 // renderer and is published to the browser process on the first navigation | 51 // renderer and is published to the browser process on the first navigation |
| 52 // after a swap. These two functions are used to set the root node's frame | 52 // after a swap. These two functions are used to set the root node's frame |
| 53 // id. | 53 // id. |
| 54 // | 54 // |
| 55 // TODO(ajwong): Remove these once RenderFrameHost's routing id replaces | 55 // TODO(ajwong): Remove these once RenderFrameHost's routing id replaces |
| 56 // frame_id. | 56 // frame_id. |
| 57 bool IsFirstNavigationAfterSwap() const; | 57 bool IsFirstNavigationAfterSwap() const; |
| 58 void OnFirstNavigationAfterSwap(int main_frame_id); | 58 void OnFirstNavigationAfterSwap(int main_frame_id); |
| 59 | 59 |
| 60 // Frame tree manipulation routines. | 60 // Frame tree manipulation routines. |
| 61 void AddFrame(int render_frame_host_id, int64 parent_frame_id, | 61 // TODO(creis): These should take in RenderFrameHost routing IDs. |
| 62 int64 frame_id, const std::string& frame_name); | 62 void AddFrame(int render_frame_host_id, |
| 63 int64 parent_frame_tree_node_id, | |
| 64 int64 frame_id, | |
| 65 const std::string& frame_name); | |
| 63 void RemoveFrame(int64 parent_frame_id, int64 frame_id); | 66 void RemoveFrame(int64 parent_frame_id, int64 frame_id); |
| 64 void SetFrameUrl(int64 frame_id, const GURL& url); | 67 void SetFrameUrl(int64 frame_id, const GURL& url); |
| 65 | 68 |
| 66 // Resets the FrameTree and changes RenderFrameHost for the main frame. | 69 // Resets the FrameTree and changes RenderFrameHost for the main frame. |
| 67 // This destroys most of the frame tree but retains the root node so that | 70 // This destroys most of the frame tree but retains the root node so that |
| 68 // navigation state may be kept on it between process swaps. Used to | 71 // navigation state may be kept on it between process swaps. Used to |
| 69 // support bookkeeping for top-level navigations. | 72 // support bookkeeping for top-level navigations. |
| 70 // | 73 // |
| 71 // If |main_frame| is NULL, reset tree to initially constructed state. | 74 // If |main_frame| is NULL, reset tree to initially constructed state. |
| 72 // | 75 // |
| 73 // TODO(ajwong): This function should not be given a |main_frame|. This is | 76 // TODO(ajwong): This function should not be given a |main_frame|. This is |
| 74 // required currently because the RenderViewHost owns its main frame. When | 77 // required currently because the RenderViewHost owns its main frame. When |
| 75 // that relation is fixed, the FrameTree should be responsible for | 78 // that relation is fixed, the FrameTree should be responsible for |
| 76 // created/destroying the main frame on the swap. | 79 // created/destroying the main frame on the swap. |
| 77 void SwapMainFrame(RenderFrameHostImpl* main_frame); | 80 void SwapMainFrame(RenderFrameHostImpl* main_frame); |
| 78 | 81 |
| 79 // Convenience accessor for the main frame's RenderFrameHostImpl. | 82 // Convenience accessor for the main frame's RenderFrameHostImpl. |
| 80 RenderFrameHostImpl* GetMainFrame() const; | 83 RenderFrameHostImpl* GetMainFrame() const; |
| 81 | 84 |
| 82 // Allows a client to listen for frame removal. | 85 // Allows a client to listen for frame removal. The listener should expect |
| 86 // to receive the RenderViewHostImpl containing the frame and the renderer- | |
| 87 // specific frame ID of the removed frame. | |
| 88 // TODO(creis): These parameters will later change to be the RenderFrameHost. | |
| 83 void SetFrameRemoveListener( | 89 void SetFrameRemoveListener( |
| 84 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); | 90 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); |
| 85 | 91 |
| 86 FrameTreeNode* GetRootForTesting() { return root_.get(); } | 92 FrameTreeNode* GetRootForTesting() { return root_.get(); } |
| 87 | 93 |
| 88 private: | 94 private: |
| 95 // Returns the FrameTreeNode with the given |frame_id|. For internal use only. | |
|
nasko
2013/11/07 14:28:00
|frame_tree_node_id|?
Charlie Reis
2013/11/07 16:49:42
No, |frame_id| is the point of this function. The
| |
| 96 // TODO(creis): Replace this with a version that takes in a routing ID. | |
| 97 FrameTreeNode* FindByFrameID(int64 frame_tree_node_id); | |
|
Charlie Reis
2013/11/07 17:10:02
Ah, here's the issue! The parameter name was wron
| |
| 98 | |
| 89 scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, | 99 scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, |
| 90 const std::string& frame_name, | 100 const std::string& frame_name, |
| 91 int render_frame_host_id, | 101 int render_frame_host_id, |
| 92 RenderProcessHost* render_process_host); | 102 RenderProcessHost* render_process_host); |
| 93 | 103 |
| 94 scoped_ptr<FrameTreeNode> root_; | 104 scoped_ptr<FrameTreeNode> root_; |
| 95 | 105 |
| 96 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; | 106 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; |
| 97 | 107 |
| 98 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 108 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
| 99 }; | 109 }; |
| 100 | 110 |
| 101 } // namespace content | 111 } // namespace content |
| 102 | 112 |
| 103 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 113 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
| OLD | NEW |