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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // There should always be such a RenderViewHost, because the main frame | 109 // There should always be such a RenderViewHost, because the main frame |
110 // RenderFrameHost for each SiteInstance should be created before subframes. | 110 // RenderFrameHost for each SiteInstance should be created before subframes. |
111 RenderViewHostImpl* GetRenderViewHostForSubFrame(SiteInstance* site_instance); | 111 RenderViewHostImpl* GetRenderViewHostForSubFrame(SiteInstance* site_instance); |
112 | 112 |
113 // Keeps track of which RenderFrameHosts are using each RenderViewHost. When | 113 // Keeps track of which RenderFrameHosts are using each RenderViewHost. When |
114 // the number drops to zero, we call Shutdown on the RenderViewHost. | 114 // the number drops to zero, we call Shutdown on the RenderViewHost. |
115 void RegisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); | 115 void RegisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
116 void UnregisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); | 116 void UnregisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
117 | 117 |
118 private: | 118 private: |
119 typedef std::pair<RenderViewHostImpl*, int> RenderViewHostRefCount; | 119 typedef base::hash_map<int, RenderViewHostImpl*> RenderViewHostMap; |
120 typedef base::hash_map<int, RenderViewHostRefCount> RenderViewHostMap; | 120 typedef std::multimap<int, RenderViewHostImpl*> RenderViewHostMultiMap; |
121 | 121 |
122 // These delegates are installed into all the RenderViewHosts and | 122 // These delegates are installed into all the RenderViewHosts and |
123 // RenderFrameHosts that we create. | 123 // RenderFrameHosts that we create. |
124 RenderFrameHostDelegate* render_frame_delegate_; | 124 RenderFrameHostDelegate* render_frame_delegate_; |
125 RenderViewHostDelegate* render_view_delegate_; | 125 RenderViewHostDelegate* render_view_delegate_; |
126 RenderWidgetHostDelegate* render_widget_delegate_; | 126 RenderWidgetHostDelegate* render_widget_delegate_; |
127 RenderFrameHostManager::Delegate* manager_delegate_; | 127 RenderFrameHostManager::Delegate* manager_delegate_; |
128 | 128 |
129 // Map of SiteInstance ID to a (RenderViewHost, refcount) pair. This allows | 129 // Map of SiteInstance ID to a RenderViewHost. This allows us to look up the |
130 // us to look up the RenderViewHost for a given SiteInstance when creating | 130 // RenderViewHost for a given SiteInstance when creating RenderFrameHosts. |
131 // RenderFrameHosts, and it allows us to call Shutdown on the RenderViewHost | 131 // Combined with the refcount on RenderViewHost, this allows us to call |
132 // and remove it from the map when no more RenderFrameHosts are using it. | 132 // Shutdown on the RenderViewHost and remove it from the map when no more |
| 133 // RenderFrameHosts are using it. |
133 // | 134 // |
134 // Must be declared before |root_| so that it is deleted afterward. Otherwise | 135 // Must be declared before |root_| so that it is deleted afterward. Otherwise |
135 // the map will be cleared before we delete the RenderFrameHosts in the tree. | 136 // the map will be cleared before we delete the RenderFrameHosts in the tree. |
136 RenderViewHostMap render_view_host_map_; | 137 RenderViewHostMap render_view_host_map_; |
137 | 138 |
| 139 // Map of SiteInstance ID to RenderViewHosts that are pending shutdown. The |
| 140 // renderers of these RVH are currently executing the unload event in |
| 141 // background. When the SwapOutACK is received, they will be deleted. In the |
| 142 // meantime, they are kept in this map, as they should not be reused (part of |
| 143 // their state is already gone away). |
| 144 RenderViewHostMultiMap render_view_host_pending_shutdown_map_; |
| 145 |
138 scoped_ptr<FrameTreeNode> root_; | 146 scoped_ptr<FrameTreeNode> root_; |
139 | 147 |
140 base::Callback<void(RenderViewHostImpl*, int)> on_frame_removed_; | 148 base::Callback<void(RenderViewHostImpl*, int)> on_frame_removed_; |
141 | 149 |
142 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 150 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
143 }; | 151 }; |
144 | 152 |
145 } // namespace content | 153 } // namespace content |
146 | 154 |
147 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 155 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
OLD | NEW |