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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 1409693009: Fix leaking of RenderFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing just the pending RF leak. Created 5 years, 2 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
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 623fd1679c52b25ea070f4fb974b3ecbe4f00856..d221f17541b28d8abd07e096b73062882913b074 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -670,6 +670,13 @@ void RenderFrameImpl::CreateFrame(
}
// static
+void RenderFrameImpl::DetachFrame(int routing_id) {
+ RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id);
+ frame->set_is_browser_initiated_detach();
+ frame->GetWebFrame()->detach();
+}
+
+// static
RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
return RenderFrameImpl::FromWebFrame(web_frame);
}
@@ -732,6 +739,7 @@ RenderFrameImpl::RenderFrameImpl(const CreateParams& params)
: frame_(NULL),
is_main_frame_(true),
is_local_root_(false),
+ is_browser_initiated_detach_(false),
render_view_(params.render_view->AsWeakPtr()),
routing_id_(params.routing_id),
is_swapped_out_(false),
@@ -2360,9 +2368,10 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) {
FrameDetached(frame));
// We only notify the browser process when the frame is being detached for
- // removal. If the frame is being detached for swap, we don't need to do this
- // since we are not modifiying the frame tree.
- if (type == DetachType::Remove)
+ // removal. If the frame is being detached for swap or the frame isn't fully
Charlie Reis 2015/10/30 20:15:44 Is this comment change stale? I'm not sure how is
nasko 2015/11/02 22:48:51 I think the confusion came from my failure to upda
+ // initialized, we don't need to do this since we are not modifiying the frame
+ // tree.
+ if (!is_browser_initiated_detach_ && type == DetachType::Remove)
Send(new FrameHostMsg_Detach(routing_id_));
// The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be
@@ -2387,7 +2396,10 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) {
// 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_main_frame_ && type == DetachType::Remove)
+ // If the frame isn't fully initialized (e.g. deleting a pending RenderFrame)
+ // it is not linked into the frame tree, so it should not be removed.
+ if (!is_browser_initiated_detach_ && !is_main_frame_ &&
Charlie Reis 2015/10/30 20:15:44 The name is confusing here as well. Whether the f
nasko 2015/11/02 22:48:51 I think this isn't correct usage here actually. Th
+ type == DetachType::Remove)
frame->parent()->removeChild(frame);
// |frame| is invalid after here. Be sure to clear frame_ as well, since this

Powered by Google App Engine
This is Rietveld 408576698