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

Side by Side Diff: content/browser/renderer_host/render_view_host.cc

Issue 6777002: Merge 79440 - Clean up unload-related state after the ack is received. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/696/src/
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 is_waiting_for_beforeunload_ack_ = true; 280 is_waiting_for_beforeunload_ack_ = true;
281 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 281 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
282 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 282 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
283 Send(new ViewMsg_ShouldClose(routing_id())); 283 Send(new ViewMsg_ShouldClose(routing_id()));
284 } 284 }
285 } 285 }
286 286
287 void RenderViewHost::ClosePage(bool for_cross_site_transition, 287 void RenderViewHost::ClosePage(bool for_cross_site_transition,
288 int new_render_process_host_id, 288 int new_render_process_host_id,
289 int new_request_id) { 289 int new_request_id) {
290 // In most cases, this will not be set to false afterward. Either the tab 290 // This will be set back to false in OnClosePageACK, just before we close the
291 // will be closed, or a pending RenderViewHost will replace this one. 291 // tab or replace it with a pending RVH. There are some cases (such as 204
292 // errors) where we'll continue to show this RVH.
292 is_waiting_for_unload_ack_ = true; 293 is_waiting_for_unload_ack_ = true;
293 // Start the hang monitor in case the renderer hangs in the unload handler. 294 // Start the hang monitor in case the renderer hangs in the unload handler.
294 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 295 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
295 296
296 ViewMsg_ClosePage_Params params; 297 ViewMsg_ClosePage_Params params;
297 params.closing_process_id = process()->id(); 298 params.closing_process_id = process()->id();
298 params.closing_route_id = routing_id(); 299 params.closing_route_id = routing_id();
299 params.for_cross_site_transition = for_cross_site_transition; 300 params.for_cross_site_transition = for_cross_site_transition;
300 params.new_render_process_host_id = new_render_process_host_id; 301 params.new_render_process_host_id = new_render_process_host_id;
301 params.new_request_id = new_request_id; 302 params.new_request_id = new_request_id;
302 if (IsRenderViewLive()) { 303 if (IsRenderViewLive()) {
303 NotificationService::current()->Notify( 304 NotificationService::current()->Notify(
304 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 305 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
305 Source<RenderViewHost>(this), 306 Source<RenderViewHost>(this),
306 NotificationService::NoDetails()); 307 NotificationService::NoDetails());
307 308
308 Send(new ViewMsg_ClosePage(routing_id(), params)); 309 Send(new ViewMsg_ClosePage(routing_id(), params));
309 } else { 310 } else {
310 // This RenderViewHost doesn't have a live renderer, so just skip closing 311 // This RenderViewHost doesn't have a live renderer, so just skip closing
311 // the page. We must notify the ResourceDispatcherHost on the IO thread, 312 // the page. We must notify the ResourceDispatcherHost on the IO thread,
312 // which we will do through the RenderProcessHost's widget helper. 313 // which we will do through the RenderProcessHost's widget helper.
313 process()->CrossSiteClosePageACK(params); 314 process()->CrossSiteClosePageACK(params);
314 } 315 }
315 } 316 }
316 317
318 void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) {
319 StopHangMonitorTimeout();
320 is_waiting_for_unload_ack_ = false;
321
322 // If this ClosePageACK is not for a cross-site transition, then it is for an
323 // attempt to close the tab. We have now finished the unload handler and can
324 // proceed with closing the tab.
325 if (!for_cross_site_transition) {
326 ClosePageIgnoringUnloadEvents();
327 }
328 }
329
317 void RenderViewHost::ClosePageIgnoringUnloadEvents() { 330 void RenderViewHost::ClosePageIgnoringUnloadEvents() {
318 StopHangMonitorTimeout(); 331 StopHangMonitorTimeout();
319 is_waiting_for_beforeunload_ack_ = false; 332 is_waiting_for_beforeunload_ack_ = false;
320 is_waiting_for_unload_ack_ = false; 333 is_waiting_for_unload_ack_ = false;
321 334
322 sudden_termination_allowed_ = true; 335 sudden_termination_allowed_ = true;
323 delegate_->Close(this); 336 delegate_->Close(this);
324 } 337 }
325 338
326 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, 339 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request,
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 LOG(DFATAL) << "Invalid checked state " << checked_state; 1715 LOG(DFATAL) << "Invalid checked state " << checked_state;
1703 return; 1716 return;
1704 } 1717 }
1705 1718
1706 CommandState state; 1719 CommandState state;
1707 state.is_enabled = is_enabled; 1720 state.is_enabled = is_enabled;
1708 state.checked_state = 1721 state.checked_state =
1709 static_cast<RenderViewCommandCheckedState>(checked_state); 1722 static_cast<RenderViewCommandCheckedState>(checked_state);
1710 command_states_[static_cast<RenderViewCommand>(command)] = state; 1723 command_states_[static_cast<RenderViewCommand>(command)] = state;
1711 } 1724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698