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 #include "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 delegate_->IsHidden()); | 117 delegate_->IsHidden()); |
| 118 | 118 |
| 119 // Keep track of renderer processes as they start to shut down or are | 119 // Keep track of renderer processes as they start to shut down or are |
| 120 // crashed/killed. | 120 // crashed/killed. |
| 121 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | 121 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 122 NotificationService::AllSources()); | 122 NotificationService::AllSources()); |
| 123 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, | 123 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 124 NotificationService::AllSources()); | 124 NotificationService::AllSources()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( | |
| 128 int32 site_instance_id) { | |
| 129 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | |
| 130 // in the SiteInstance, then tell their respective FrameTrees to remove all | |
| 131 // swapped out RenderFrameHosts corresponding to them. | |
| 132 // TODO(creis): Replace this with a RenderFrameHostIterator that protects | |
| 133 // against use-after-frees if a later element is deleted before getting to it. | |
| 134 scoped_ptr<RenderWidgetHostIterator> widgets( | |
| 135 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); | |
| 136 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | |
| 137 if (!widget->IsRenderView()) | |
| 138 continue; | |
| 139 RenderViewHostImpl* rvh = | |
| 140 static_cast<RenderViewHostImpl*>(RenderViewHost::From(widget)); | |
| 141 if (site_instance_id == rvh->GetSiteInstance()->GetId()) { | |
| 142 // This deletes all RenderFrameHosts using the |rvh|, which then causes | |
| 143 // |rvh| to Shutdown. | |
| 144 FrameTree* tree = rvh->GetDelegate()->GetFrameTree(); | |
| 145 tree->ForEach(base::Bind( | |
| 146 &RenderFrameHostManager::ClearSwappedOutRFHsInSiteInstance, | |
| 147 site_instance_id)); | |
| 148 } | |
| 149 } | |
| 150 } | |
| 151 | |
| 127 RenderViewHostImpl* RenderFrameHostManager::current_host() const { | 152 RenderViewHostImpl* RenderFrameHostManager::current_host() const { |
| 128 if (!render_frame_host_) | 153 if (!render_frame_host_) |
| 129 return NULL; | 154 return NULL; |
| 130 return render_frame_host_->render_view_host(); | 155 return render_frame_host_->render_view_host(); |
| 131 } | 156 } |
| 132 | 157 |
| 133 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const { | 158 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const { |
| 134 if (!pending_render_frame_host_) | 159 if (!pending_render_frame_host_) |
| 135 return NULL; | 160 return NULL; |
| 136 return pending_render_frame_host_->render_view_host(); | 161 return pending_render_frame_host_->render_view_host(); |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 active_view_count()) { | 1174 active_view_count()) { |
| 1150 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); | 1175 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); |
| 1151 // This is deleted while cleaning up the SiteInstance's views. | 1176 // This is deleted while cleaning up the SiteInstance's views. |
| 1152 old_render_frame_host = NULL; | 1177 old_render_frame_host = NULL; |
| 1153 } | 1178 } |
| 1154 } else { | 1179 } else { |
| 1155 delete old_render_frame_host; | 1180 delete old_render_frame_host; |
| 1156 } | 1181 } |
| 1157 } | 1182 } |
| 1158 | 1183 |
| 1159 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( | |
| 1160 int32 site_instance_id) { | |
| 1161 // First remove any swapped out RFH for this SiteInstance from our own list. | |
| 1162 ClearSwappedOutRFHsInSiteInstance(site_instance_id, frame_tree_node_); | |
|
sadrul
2014/02/14 13:20:51
I removed this line when making this a static func
| |
| 1163 | |
| 1164 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | |
| 1165 // in the SiteInstance, then tell their respective FrameTrees to remove all | |
| 1166 // swapped out RenderFrameHosts corresponding to them. | |
| 1167 // TODO(creis): Replace this with a RenderFrameHostIterator that protects | |
| 1168 // against use-after-frees if a later element is deleted before getting to it. | |
| 1169 scoped_ptr<RenderWidgetHostIterator> widgets( | |
| 1170 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); | |
| 1171 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | |
| 1172 if (!widget->IsRenderView()) | |
| 1173 continue; | |
| 1174 RenderViewHostImpl* rvh = | |
| 1175 static_cast<RenderViewHostImpl*>(RenderViewHost::From(widget)); | |
| 1176 if (site_instance_id == rvh->GetSiteInstance()->GetId()) { | |
| 1177 // This deletes all RenderFrameHosts using the |rvh|, which then causes | |
| 1178 // |rvh| to Shutdown. | |
| 1179 FrameTree* tree = rvh->GetDelegate()->GetFrameTree(); | |
| 1180 tree->ForEach(base::Bind( | |
| 1181 &RenderFrameHostManager::ClearSwappedOutRFHsInSiteInstance, | |
| 1182 site_instance_id)); | |
| 1183 } | |
| 1184 } | |
| 1185 } | |
| 1186 | |
| 1187 RenderFrameHostImpl* RenderFrameHostManager::UpdateRendererStateForNavigate( | 1184 RenderFrameHostImpl* RenderFrameHostManager::UpdateRendererStateForNavigate( |
| 1188 const NavigationEntryImpl& entry) { | 1185 const NavigationEntryImpl& entry) { |
| 1189 // If we are currently navigating cross-process, we want to get back to normal | 1186 // If we are currently navigating cross-process, we want to get back to normal |
| 1190 // and then navigate as usual. | 1187 // and then navigate as usual. |
| 1191 if (cross_navigation_pending_) { | 1188 if (cross_navigation_pending_) { |
| 1192 if (pending_render_frame_host_) | 1189 if (pending_render_frame_host_) |
| 1193 CancelPending(); | 1190 CancelPending(); |
| 1194 cross_navigation_pending_ = false; | 1191 cross_navigation_pending_ = false; |
| 1195 } | 1192 } |
| 1196 | 1193 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1441 SiteInstance* instance) const { | 1438 SiteInstance* instance) const { |
| 1442 RenderFrameHostMap::const_iterator iter = | 1439 RenderFrameHostMap::const_iterator iter = |
| 1443 swapped_out_hosts_.find(instance->GetId()); | 1440 swapped_out_hosts_.find(instance->GetId()); |
| 1444 if (iter != swapped_out_hosts_.end()) | 1441 if (iter != swapped_out_hosts_.end()) |
| 1445 return iter->second; | 1442 return iter->second; |
| 1446 | 1443 |
| 1447 return NULL; | 1444 return NULL; |
| 1448 } | 1445 } |
| 1449 | 1446 |
| 1450 } // namespace content | 1447 } // namespace content |
| OLD | NEW |