Chromium Code Reviews| Index: content/renderer/render_frame_impl.cc |
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
| index e8212f8384d53459d2a508387b458a49739ca0a2..1ee07f35f6b251f464dac31a56fb355087b9786f 100644 |
| --- a/content/renderer/render_frame_impl.cc |
| +++ b/content/renderer/render_frame_impl.cc |
| @@ -7,7 +7,6 @@ |
| #include <map> |
| #include <string> |
| -#include "base/command_line.h" |
| #include "base/i18n/char_iterator.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/time/time.h" |
| @@ -140,6 +139,11 @@ RenderFrameImpl::~RenderFrameImpl() { |
| RenderThread::Get()->RemoveRoute(routing_id_); |
| } |
| +// TODO(nasko): Remove this hack once the bug is found. |
|
Charlie Reis
2013/12/20 01:42:57
Please add a comment saying how this will help cat
nasko
2013/12/27 21:49:47
Done.
|
| +void RenderFrameImpl::operator delete(void* ptr) { |
| + memset(ptr, 0xAF, sizeof(RenderFrameImpl)); |
|
Charlie Reis
2013/12/20 01:42:57
Albert, can you take a look at this part? I'd lik
awong
2013/12/20 02:06:42
Yep...this is the way partition alloc works.
I th
|
| +} |
| + |
| void RenderFrameImpl::MainWebFrameCreated(blink::WebFrame* frame) { |
| FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| WebFrameCreated(frame)); |
| @@ -601,31 +605,28 @@ void RenderFrameImpl::didAccessInitialDocument(blink::WebFrame* frame) { |
| blink::WebFrame* RenderFrameImpl::createChildFrame( |
| blink::WebFrame* parent, |
| const blink::WebString& name) { |
| - RenderFrameImpl* child_render_frame = this; |
| long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| - // Synchronously notify the browser of a child frame creation to get the |
| - // routing_id for the RenderFrame. |
| - int routing_id; |
| - Send(new FrameHostMsg_CreateChildFrame(routing_id_, |
| - parent->identifier(), |
| - child_frame_identifier, |
| - UTF16ToUTF8(name), |
| - &routing_id)); |
| - child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); |
| - } |
| + // Synchronously notify the browser of a child frame creation to get the |
| + // routing_id for the RenderFrame. |
| + int routing_id = MSG_ROUTING_NONE; |
| + Send(new FrameHostMsg_CreateChildFrame(routing_id_, |
| + parent->identifier(), |
| + child_frame_identifier, |
| + UTF16ToUTF8(name), |
| + &routing_id)); |
| + if (routing_id == MSG_ROUTING_NONE) |
| + return NULL; |
| + RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(render_view_, |
| + routing_id); |
| blink::WebFrame* web_frame = WebFrame::create(child_render_frame, |
| child_frame_identifier); |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| - g_child_frame_map.Get().insert( |
| - std::make_pair(web_frame, child_render_frame)); |
| - } else { |
| - FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| - WebFrameCreated(web_frame)); |
| - } |
| + g_child_frame_map.Get().insert( |
| + std::make_pair(web_frame, child_render_frame)); |
| + FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| + WebFrameCreated(web_frame)); |
| return web_frame; |
| } |
| @@ -639,45 +640,41 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { |
| // called on the parent frame. |
| CHECK(!is_detaching_); |
| + bool is_subframe = !!frame->parent(); |
| int64 parent_frame_id = -1; |
| - if (frame->parent()) |
| + if (is_subframe) |
| parent_frame_id = frame->parent()->identifier(); |
| Send(new FrameHostMsg_Detach(routing_id_, parent_frame_id, |
| frame->identifier())); |
| - // Currently multiple WebCore::Frames can send frameDetached to a single |
| - // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served |
| - // as a shared WebFrameClient for multiple Webcore::Frame objects. It also |
| - // prevents this class from entering the |is_detaching_| state because |
| - // even though one WebCore::Frame may have detached itself, others will |
| - // still need to use this object. |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| - // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
| - // sent before setting |is_detaching_| to true. In contrast, Observers |
| - // should only be notified afterwards so they cannot call back into and |
| - // have IPCs fired off. |
| - is_detaching_ = true; |
| - } |
| + // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
| + // sent before setting |is_detaching_| to true. In contrast, Observers |
| + // should only be notified afterwards so they cannot call back into and |
| + // have IPCs fired off. |
| + is_detaching_ = true; |
| // Call back to RenderViewImpl for observers to be notified. |
| // TODO(nasko): Remove once we have RenderFrameObserver. |
| render_view_->frameDetached(frame); |
| + // 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 it does |
| + // not require any cleanup here. |
| + if (is_subframe) { |
| + FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
| + CHECK(it != g_child_frame_map.Get().end()); |
| + CHECK_EQ(it->second, this); |
| + g_child_frame_map.Get().erase(it); |
| + } |
| + |
| + // |frame| is invalid after here. |
| frame->close(); |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| - // If the frame does not have a parent, it is the main frame. The main |
| - // frame is owned by the containing RenderViewHost so it does not require |
| - // any cleanup here. |
| - if (frame->parent()) { |
| - FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
| - DCHECK(it != g_child_frame_map.Get().end()); |
| - DCHECK_EQ(it->second, this); |
| - g_child_frame_map.Get().erase(it); |
| - delete this; |
| - // Object is invalid after this point. |
| - } |
| + if (is_subframe) { |
| + delete this; |
| + // Object is invalid after this point. |
| } |
| } |