Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 1229083002: Clean up some detach logic in RenderFrameImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Less braces Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 76876a975575c4f4897ad0a10f20249e51263eee..7005fdd66b83c004a1b45dac7c53f7973f5d4082 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2172,6 +2172,9 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) {
// sent before setting |is_detaching_| to true.
is_detaching_ = true;
+ if (render_widget_)
+ render_widget_->UnregisterRenderFrame(this);
+
// We need to clean up subframes by removing them from the map and deleting
// the RenderFrameImpl. In contrast, the main frame is owned by its
// containing RenderViewHost (so that they have the same lifetime), so only
@@ -2181,18 +2184,11 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) {
CHECK_EQ(it->second, this);
g_frame_map.Get().erase(it);
- if (is_subframe_) {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSitePerProcess) && render_widget_) {
- render_widget_->UnregisterRenderFrame(this);
- }
-
- // Only remove the frame from the renderer's frame tree if the frame is
- // being detached for removal. For swaps, WebFrame::swap already takes care
- // of replacing the frame with a RemoteFrame.
- if (type == DetachType::Remove)
- frame->parent()->removeChild(frame);
- }
+ // Only remove the frame from the renderer's frame tree if the frame is
+ // being detached for removal. In the case of a swap, the frame needs to
+ // remain in the tree so WebFrame::swap() can replace it with the new frame.
+ if (is_subframe_ && type == DetachType::Remove)
+ frame->parent()->removeChild(frame);
// |frame| is invalid after here. Be sure to clear frame_ as well, since this
// object may not be deleted immediately and other methods may try to access
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698