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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1968933002: Fix: tabs slow to response to beforeunload are closed prematurely. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Correct order of checks Created 4 years, 7 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3362cc1b63417be749ef6832eabd73c03b175083..977bcb5d9331fd1d61c5f9789c85836d927fc8ef 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4553,27 +4553,28 @@ void WebContentsImpl::RendererUnresponsive(
if (DevToolsAgentHost::IsDebuggerAttached(this))
return;
- if (rfhi->is_waiting_for_beforeunload_ack() ||
- rfhi->IsWaitingForUnloadACK()) {
- // Hang occurred while firing the beforeunload/unload handler.
+ // We might have been waiting for both beforeunload and unload ACK.
+ // Check if tab is to be unloaded first.
+ if (rfhi->IsWaitingForUnloadACK()) {
+ // Hang occurred while firing the unload handler.
// Pretend the handler fired so tab closing continues as if it had.
GetRenderViewHost()->set_sudden_termination_allowed(true);
if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer())
return;
- // If the tab hangs in the beforeunload/unload handler there's really
- // nothing we can do to recover. If the hang is in the beforeunload handler,
- // pretend the beforeunload listeners have all fired and allow the delegate
- // to continue closing; the user will not have the option of cancelling the
- // close. Otherwise, pretend the unload listeners have all fired and close
+ // If the tab hangs in the unload handler there's really nothing we can do
+ // to recover. Pretend the unload listeners have all fired and close
// the tab.
- bool close = true;
- if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) {
- delegate_->BeforeUnloadFired(this, true, &close);
- }
- if (close)
- Close();
+ Close();
+ return;
+ }
+
+ if (rfhi->is_waiting_for_beforeunload_ack()) {
+ // If the hang is in the beforeunload handler, pretend the beforeunload
+ // listeners have all fired and allow the delegate to continue closing;
+ // the user will not have the option of cancelling the close.
+ rfhi->SimulateBeforeUnloadAck();
return;
}
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698