Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index e6cc05197d3a25613468d2938787f3f54da90757..821be812fce862c4134dec1cc90155f2b13bae1d 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -920,6 +920,9 @@ void RenderFrameHostImpl::SwapOut( |
| replication_state = proxy->frame_tree_node()->current_replication_state(); |
| } |
| + // TODO(clamy): if the frame has no unload handlers and |proxy| is null, it |
| + // could be discarded immediately, improving performance. However that means |
| + // losing the last sync of PageState. |
| if (IsRenderFrameLive()) { |
| Send(new FrameMsg_SwapOut(routing_id_, proxy_routing_id, is_loading, |
| replication_state)); |
| @@ -1551,10 +1554,17 @@ void RenderFrameHostImpl::Stop() { |
| } |
| void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { |
| - // TODO(creis): Support beforeunload on subframes. For now just pretend that |
| + // Skip running beforeUnload if: |
| + // - the renderer is not live. |
| + // - the frame is a subframe. |
| + // - this is a cross-site navigation and the current frame has no |
| + // beforeUnload handler registered. |
| + // TODO(creis): Support beforeUnload on subframes. For now just pretend that |
| // the handler ran and allowed the navigation to proceed. |
| - if (GetParent() || !IsRenderFrameLive()) { |
| - // We don't have a live renderer, so just skip running beforeunload. |
| + // TODO(clamy): Skip beforeUnload when closing a frame with no registered |
| + // beforeUnload handlers. |
|
clamy
2015/02/16 17:43:53
We currently only skip waiting for beforeUnload in
|
| + if (GetParent() || !IsRenderFrameLive() || |
| + (!has_beforeunload_handlers_ && for_navigation)) { |
| if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnableBrowserSideNavigation)) { |
| frame_tree_node_->navigator()->OnBeforeUnloadACK( |