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 16 matching lines...) Expand all Loading... |
27 // all FrameTreeNodes will be created/deleted in response to frame attach and | 27 // all FrameTreeNodes will be created/deleted in response to frame attach and |
28 // detach events in the DOM. | 28 // detach events in the DOM. |
29 // | 29 // |
30 // The main frame's FrameTreeNode is special in that it is reused. This allows | 30 // The main frame's FrameTreeNode is special in that it is reused. This allows |
31 // it to serve as an anchor for state that needs to persist across top-level | 31 // it to serve as an anchor for state that needs to persist across top-level |
32 // page navigations. | 32 // page navigations. |
33 // | 33 // |
34 // TODO(ajwong): Move NavigationController ownership to the main frame | 34 // TODO(ajwong): Move NavigationController ownership to the main frame |
35 // FrameTreeNode. Possibly expose access to it from here. | 35 // FrameTreeNode. Possibly expose access to it from here. |
36 // | 36 // |
37 // TODO(ajwong): Currently this class only contains FrameTreeNodes for | |
38 // subframes if the --site-per-process flag is enabled. | |
39 // | |
40 // This object is only used on the UI thread. | 37 // This object is only used on the UI thread. |
41 class CONTENT_EXPORT FrameTree { | 38 class CONTENT_EXPORT FrameTree { |
42 public: | 39 public: |
43 // Each FrameTreeNode will default to using the given |navigator| for | 40 // Each FrameTreeNode will default to using the given |navigator| for |
44 // navigation tasks in the frame. | 41 // navigation tasks in the frame. |
45 // A set of delegates are remembered here so that we can create | 42 // A set of delegates are remembered here so that we can create |
46 // RenderFrameHostManagers. | 43 // RenderFrameHostManagers. |
47 // TODO(creis): This set of delegates will change as we move things to | 44 // TODO(creis): This set of delegates will change as we move things to |
48 // Navigator. | 45 // Navigator. |
49 FrameTree(Navigator* navigator, | 46 FrameTree(Navigator* navigator, |
50 RenderFrameHostDelegate* render_frame_delegate, | 47 RenderFrameHostDelegate* render_frame_delegate, |
51 RenderViewHostDelegate* render_view_delegate, | 48 RenderViewHostDelegate* render_view_delegate, |
52 RenderWidgetHostDelegate* render_widget_delegate, | 49 RenderWidgetHostDelegate* render_widget_delegate, |
53 RenderFrameHostManager::Delegate* manager_delegate); | 50 RenderFrameHostManager::Delegate* manager_delegate); |
54 ~FrameTree(); | 51 ~FrameTree(); |
55 | 52 |
56 FrameTreeNode* root() const { return root_.get(); } | 53 FrameTreeNode* root() const { return root_.get(); } |
57 | 54 |
58 // Returns the FrameTreeNode with the given |frame_tree_node_id|. | 55 // Returns the FrameTreeNode with the given |frame_tree_node_id|. |
59 FrameTreeNode* FindByID(int64 frame_tree_node_id); | 56 FrameTreeNode* FindByID(int64 frame_tree_node_id); |
60 | 57 |
61 // Executes |on_node| on each node in the frame tree. If |on_node| returns | 58 // Executes |on_node| on each node in the frame tree. If |on_node| returns |
62 // false, terminates the iteration immediately. Returning false is useful | 59 // false, terminates the iteration immediately. Returning false is useful |
63 // if |on_node| is just doing a search over the tree. | 60 // if |on_node| is just doing a search over the tree. |
64 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | 61 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
65 | 62 |
66 // After the FrameTree is created, or after SwapMainFrame() has been called, | |
67 // the root node does not yet have a frame id. This is allocated by the | |
68 // renderer and is published to the browser process on the first navigation | |
69 // after a swap. These two functions are used to set the root node's frame | |
70 // id. | |
71 // | |
72 // TODO(ajwong): Remove these once RenderFrameHost's routing id replaces | |
73 // frame_id. | |
74 bool IsFirstNavigationAfterSwap() const; | |
75 void OnFirstNavigationAfterSwap(int main_frame_id); | |
76 | |
77 // Frame tree manipulation routines. | 63 // Frame tree manipulation routines. |
78 // TODO(creis): These should take in RenderFrameHost routing IDs. | 64 // TODO(creis): These should take in RenderFrameHost routing IDs. |
79 RenderFrameHostImpl* AddFrame(int frame_routing_id, | 65 RenderFrameHostImpl* AddFrame(RenderViewHostImpl* parent_render_view_host, |
80 int64 parent_frame_tree_node_id, | 66 int frame_routing_id, |
| 67 int64 parent_frame_id, |
81 int64 frame_id, | 68 int64 frame_id, |
82 const std::string& frame_name); | 69 const std::string& frame_name); |
| 70 // TODO(creis): Remove |frame_id|. |
83 void RemoveFrame(RenderFrameHostImpl* render_frame_host, | 71 void RemoveFrame(RenderFrameHostImpl* render_frame_host, |
84 int64 parent_frame_id, | 72 int64 parent_frame_tree_node_id, |
| 73 int64 frame_tree_node_id, |
85 int64 frame_id); | 74 int64 frame_id); |
86 void SetFrameUrl(int64 frame_id, const GURL& url); | 75 void SetFrameUrl(int64 frame_tree_node_id, const GURL& url); |
87 | 76 |
88 // Clears process specific-state after a main frame process swap. | 77 // Clears process specific-state after a main frame process swap. |
89 // This destroys most of the frame tree but retains the root node so that | 78 // This destroys most of the frame tree but retains the root node so that |
90 // navigation state may be kept on it between process swaps. Used to | 79 // navigation state may be kept on it between process swaps. Used to |
91 // support bookkeeping for top-level navigations. | 80 // support bookkeeping for top-level navigations. |
92 // TODO(creis): Look into how we can remove the need for this method. | 81 // TODO(creis): Look into how we can remove the need for this method. |
93 void ResetForMainFrameSwap(); | 82 void ResetForMainFrameSwap(); |
94 | 83 |
95 // Convenience accessor for the main frame's RenderFrameHostImpl. | 84 // Convenience accessor for the main frame's RenderFrameHostImpl. |
96 RenderFrameHostImpl* GetMainFrame() const; | 85 RenderFrameHostImpl* GetMainFrame() const; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 scoped_ptr<FrameTreeNode> root_; | 141 scoped_ptr<FrameTreeNode> root_; |
153 | 142 |
154 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; | 143 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; |
155 | 144 |
156 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 145 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
157 }; | 146 }; |
158 | 147 |
159 } // namespace content | 148 } // namespace content |
160 | 149 |
161 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 150 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
OLD | NEW |