| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // top-down and visits a node before adding its children to the queue, making | 64 // top-down and visits a node before adding its children to the queue, making |
| 65 // it safe to remove children during the callback. | 65 // it safe to remove children during the callback. |
| 66 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | 66 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
| 67 | 67 |
| 68 // Frame tree manipulation routines. | 68 // Frame tree manipulation routines. |
| 69 RenderFrameHostImpl* AddFrame(FrameTreeNode* parent, | 69 RenderFrameHostImpl* AddFrame(FrameTreeNode* parent, |
| 70 int new_routing_id, | 70 int new_routing_id, |
| 71 const std::string& frame_name); | 71 const std::string& frame_name); |
| 72 void RemoveFrame(FrameTreeNode* child); | 72 void RemoveFrame(FrameTreeNode* child); |
| 73 | 73 |
| 74 // This method walks the entire frame tree and creates a RenderFrameProxyHost |
| 75 // for the given |site_instance| in each node except the |source| one -- |
| 76 // the source will have a RenderFrameHost. It assumes that no frame tree |
| 77 // nodes already have RenderFrameProxyHost for the given |site_instance|. |
| 78 void CreateProxiesForSiteInstance( |
| 79 FrameTreeNode* source, |
| 80 SiteInstance* site_instance); |
| 81 |
| 74 // Clears process specific-state after a main frame process swap. | 82 // Clears process specific-state after a main frame process swap. |
| 75 // This destroys most of the frame tree but retains the root node so that | 83 // This destroys most of the frame tree but retains the root node so that |
| 76 // navigation state may be kept on it between process swaps. Used to | 84 // navigation state may be kept on it between process swaps. Used to |
| 77 // support bookkeeping for top-level navigations. | 85 // support bookkeeping for top-level navigations. |
| 78 // TODO(creis): Look into how we can remove the need for this method. | 86 // TODO(creis): Look into how we can remove the need for this method. |
| 79 void ResetForMainFrameSwap(); | 87 void ResetForMainFrameSwap(); |
| 80 | 88 |
| 81 // Update the frame tree after a process exits. Any nodes currently using the | 89 // Update the frame tree after a process exits. Any nodes currently using the |
| 82 // given |render_view_host| will lose all their children. | 90 // given |render_view_host| will lose all their children. |
| 83 // TODO(creis): This should take a RenderProcessHost once RenderFrameHost | 91 // TODO(creis): This should take a RenderProcessHost once RenderFrameHost |
| 84 // knows its process. Until then, we would just be asking the RenderViewHost | 92 // knows its process. Until then, we would just be asking the RenderViewHost |
| 85 // for its process, so we'll skip that step. | 93 // for its process, so we'll skip that step. |
| 86 void RenderProcessGone(RenderViewHost* render_view_host); | 94 void RenderProcessGone(RenderViewHost* render_view_host); |
| 87 | 95 |
| 88 // Convenience accessor for the main frame's RenderFrameHostImpl. | 96 // Convenience accessor for the main frame's RenderFrameHostImpl. |
| 89 RenderFrameHostImpl* GetMainFrame() const; | 97 RenderFrameHostImpl* GetMainFrame() const; |
| 90 | 98 |
| 91 // Returns the focused frame. | 99 // Returns the focused frame. |
| 92 FrameTreeNode* GetFocusedFrame(); | 100 FrameTreeNode* GetFocusedFrame(); |
| 93 | 101 |
| 94 // Sets the focused frame. | 102 // Sets the focused frame. |
| 95 void SetFocusedFrame(FrameTreeNode* node); | 103 void SetFocusedFrame(FrameTreeNode* node); |
| 96 | 104 |
| 97 // Allows a client to listen for frame removal. The listener should expect | 105 // Allows a client to listen for frame removal. The listener should expect |
| 98 // to receive the RenderViewHostImpl containing the frame and the renderer- | 106 // to receive the RenderViewHostImpl containing the frame and the renderer- |
| 99 // specific frame routing ID of the removed frame. | 107 // specific frame routing ID of the removed frame. |
| 100 void SetFrameRemoveListener( | 108 void SetFrameRemoveListener( |
| 101 const base::Callback<void(RenderFrameHost*)>& on_frame_removed); | 109 const base::Callback<void(RenderFrameHost*)>& on_frame_removed); |
| 102 | 110 |
| 103 // Creates a RenderViewHost for a new main frame RenderFrameHost in the given | 111 // Creates a RenderViewHost for a new RenderFrameHost in the given |
| 104 // |site_instance|. The RenderViewHost will have its Shutdown method called | 112 // |site_instance|. The RenderViewHost will have its Shutdown method called |
| 105 // when all of the RenderFrameHosts using it are deleted. | 113 // when all of the RenderFrameHosts using it are deleted. |
| 106 RenderViewHostImpl* CreateRenderViewHostForMainFrame( | 114 RenderViewHostImpl* CreateRenderViewHost(SiteInstance* site_instance, |
| 107 SiteInstance* site_instance, | 115 int routing_id, |
| 108 int routing_id, | 116 int main_frame_routing_id, |
| 109 int main_frame_routing_id, | 117 bool swapped_out, |
| 110 bool swapped_out, | 118 bool hidden); |
| 111 bool hidden); | |
| 112 | 119 |
| 113 // Returns the existing RenderViewHost for a new subframe RenderFrameHost. | 120 // Returns the existing RenderViewHost for a new RenderFrameHost. |
| 114 // There should always be such a RenderViewHost, because the main frame | 121 // There should always be such a RenderViewHost, because the main frame |
| 115 // RenderFrameHost for each SiteInstance should be created before subframes. | 122 // RenderFrameHost for each SiteInstance should be created before subframes. |
| 116 RenderViewHostImpl* GetRenderViewHostForSubFrame(SiteInstance* site_instance); | 123 RenderViewHostImpl* GetRenderViewHost(SiteInstance* site_instance); |
| 117 | 124 |
| 118 // Keeps track of which RenderFrameHosts are using each RenderViewHost. When | 125 // Keeps track of which RenderFrameHosts are using each RenderViewHost. When |
| 119 // the number drops to zero, we call Shutdown on the RenderViewHost. | 126 // the number drops to zero, we call Shutdown on the RenderViewHost. |
| 120 void RegisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); | 127 void RegisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
| 121 void UnregisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); | 128 void UnregisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
| 122 | 129 |
| 123 private: | 130 private: |
| 124 typedef base::hash_map<int, RenderViewHostImpl*> RenderViewHostMap; | 131 typedef base::hash_map<int, RenderViewHostImpl*> RenderViewHostMap; |
| 125 typedef std::multimap<int, RenderViewHostImpl*> RenderViewHostMultiMap; | 132 typedef std::multimap<int, RenderViewHostImpl*> RenderViewHostMultiMap; |
| 126 | 133 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 153 int64 focused_frame_tree_node_id_; | 160 int64 focused_frame_tree_node_id_; |
| 154 | 161 |
| 155 base::Callback<void(RenderFrameHost*)> on_frame_removed_; | 162 base::Callback<void(RenderFrameHost*)> on_frame_removed_; |
| 156 | 163 |
| 157 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 164 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
| 158 }; | 165 }; |
| 159 | 166 |
| 160 } // namespace content | 167 } // namespace content |
| 161 | 168 |
| 162 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 169 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
| OLD | NEW |