Index: content/browser/renderer_host/render_view_host.cc |
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc |
index 7440df18bf7dcea47e8ea6577c5d87d6b060636f..232bc4eb6e3c1b9cadfb1a72d4af0b1ba615fb5c 100644 |
--- a/content/browser/renderer_host/render_view_host.cc |
+++ b/content/browser/renderer_host/render_view_host.cc |
@@ -97,7 +97,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, |
delegate_(delegate), |
waiting_for_drag_context_response_(false), |
enabled_bindings_(0), |
- pending_request_id_(0), |
+ pending_request_id_(-1), |
navigations_suspended_(false), |
suspended_nav_message_(NULL), |
run_modal_reply_msg_(NULL), |
@@ -300,45 +300,53 @@ void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { |
} |
} |
-void RenderViewHost::ClosePage(bool for_cross_site_transition, |
- int new_render_process_host_id, |
- int new_request_id) { |
- // This will be set back to false in OnClosePageACK, just before we close the |
- // tab or replace it with a pending RVH. There are some cases (such as 204 |
- // errors) where we'll continue to show this RVH. |
+void RenderViewHost::SwapOut(int new_render_process_host_id, |
+ int new_request_id) { |
+ // This will be set back to false in OnSwapOutACK, just before we replace |
+ // this RVH with the pending RVH. Note there are some cases (such as 204 |
+ // responses) where we'll continue to show this RVH. |
is_waiting_for_unload_ack_ = true; |
// Start the hang monitor in case the renderer hangs in the unload handler. |
StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
- ViewMsg_ClosePage_Params params; |
+ ViewMsg_SwapOut_Params params; |
params.closing_process_id = process()->id(); |
params.closing_route_id = routing_id(); |
- params.for_cross_site_transition = for_cross_site_transition; |
params.new_render_process_host_id = new_render_process_host_id; |
params.new_request_id = new_request_id; |
if (IsRenderViewLive()) { |
- NotificationService::current()->Notify( |
- NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
- Source<RenderViewHost>(this), |
- NotificationService::NoDetails()); |
- |
- Send(new ViewMsg_ClosePage(routing_id(), params)); |
+ Send(new ViewMsg_SwapOut(routing_id(), params)); |
} else { |
- // This RenderViewHost doesn't have a live renderer, so just skip closing |
- // the page. We must notify the ResourceDispatcherHost on the IO thread, |
+ // This RenderViewHost doesn't have a live renderer, so just skip the unload |
+ // event. We must notify the ResourceDispatcherHost on the IO thread, |
// which we will do through the RenderProcessHost's widget helper. |
- process()->CrossSiteClosePageACK(params); |
+ process()->CrossSiteSwapOutACK(params); |
} |
} |
-void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) { |
+void RenderViewHost::OnSwapOutACK() { |
+ // Stop the hang monitor now that the unload handler has finished. |
StopHangMonitorTimeout(); |
is_waiting_for_unload_ack_ = false; |
+} |
+ |
+void RenderViewHost::ClosePage() { |
+ // Start the hang monitor in case the renderer hangs in the unload handler. |
+ is_waiting_for_unload_ack_ = true; |
+ StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
- // If this ClosePageACK is not for a cross-site transition, then it is for an |
- // attempt to close the tab. We have now finished the unload handler and can |
- // proceed with closing the tab. |
- if (!for_cross_site_transition) { |
+ if (IsRenderViewLive()) { |
+ // TODO(creis): Should this be moved to Shutdown? It may not be called for |
+ // RenderViewHosts that have been swapped out. |
+ NotificationService::current()->Notify( |
+ NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
+ Source<RenderViewHost>(this), |
+ NotificationService::NoDetails()); |
+ |
+ Send(new ViewMsg_ClosePage(routing_id())); |
+ } else { |
+ // This RenderViewHost doesn't have a live renderer, so just skip the unload |
+ // event and close the page. |
ClosePageIgnoringUnloadEvents(); |
} |
} |
@@ -780,6 +788,7 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { |
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) |
IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
OnAccessibilityNotifications) |
@@ -1304,6 +1313,10 @@ void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { |
} |
} |
+void RenderViewHost::OnMsgClosePageACK() { |
+ ClosePageIgnoringUnloadEvents(); |
+} |
+ |
void RenderViewHost::WindowMoveOrResizeStarted() { |
Send(new ViewMsg_MoveOrResizeStarted(routing_id())); |
} |