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

Side by Side 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: Revisited solution 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4545 return; 4545 return;
4546 4546
4547 RenderFrameHostImpl* rfhi = 4547 RenderFrameHostImpl* rfhi =
4548 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); 4548 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame());
4549 4549
4550 // Ignore renderer unresponsive event if debugger is attached to the tab 4550 // Ignore renderer unresponsive event if debugger is attached to the tab
4551 // since the event may be a result of the renderer sitting on a breakpoint. 4551 // since the event may be a result of the renderer sitting on a breakpoint.
4552 // See http://crbug.com/65458 4552 // See http://crbug.com/65458
4553 if (DevToolsAgentHost::IsDebuggerAttached(this)) 4553 if (DevToolsAgentHost::IsDebuggerAttached(this))
4554 return; 4554 return;
4555
4556 if (rfhi->is_waiting_for_beforeunload_ack() || 4555 if (rfhi->is_waiting_for_beforeunload_ack() ||
4557 rfhi->IsWaitingForUnloadACK()) { 4556 rfhi->IsWaitingForUnloadACK()) {
4558 // Hang occurred while firing the beforeunload/unload handler. 4557 // Hang occurred while firing the beforeunload/unload handler.
4559 // Pretend the handler fired so tab closing continues as if it had. 4558 // Pretend the handler fired so tab closing continues as if it had.
4560 GetRenderViewHost()->set_sudden_termination_allowed(true); 4559 GetRenderViewHost()->set_sudden_termination_allowed(true);
4561 4560
4562 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) 4561 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer())
4563 return; 4562 return;
4564 4563
4565 // If the tab hangs in the beforeunload/unload handler there's really 4564 // If the tab hangs in the beforeunload/unload handler there's really
4566 // nothing we can do to recover. If the hang is in the beforeunload handler, 4565 // nothing we can do to recover. If the hang is in the beforeunload handler,
4567 // pretend the beforeunload listeners have all fired and allow the delegate 4566 // pretend the beforeunload listeners have all fired and allow the delegate
4568 // to continue closing; the user will not have the option of cancelling the 4567 // to continue closing; the user will not have the option of cancelling the
4569 // close. Otherwise, pretend the unload listeners have all fired and close 4568 // close. Otherwise, pretend the unload listeners have all fired and close
4570 // the tab. 4569 // the tab.
4571 bool close = true; 4570 bool close = true;
4572 if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) { 4571 if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) {
4573 delegate_->BeforeUnloadFired(this, true, &close); 4572 delegate_->BeforeUnloadFired(this, true, &close);
4573 // Reset flag so we don't get duplicate of of ACK or run into
4574 // situation when we have both |is_waiting_for_beforeunload_ack| and
4575 // |IsWaitingForUnloadACK| on.
4576 rfhi->DontWaitForBeforeUnloadAck();
Charlie Reis 2016/05/13 22:24:01 I wonder if we should expose and call RFHI::OnBefo
Mikhail Goncharov 2016/05/16 05:02:01 I have inspected RenderFrameHostImpl::OnBeforeUnlo
4574 } 4577 }
4575 if (close) 4578 if (close)
4576 Close(); 4579 Close();
4577 return; 4580 return;
4578 } 4581 }
4579 4582
4580 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) 4583 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive())
4581 return; 4584 return;
4582 4585
4583 if (delegate_) 4586 if (delegate_)
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 for (RenderViewHost* render_view_host : render_view_host_set) 5036 for (RenderViewHost* render_view_host : render_view_host_set)
5034 render_view_host->OnWebkitPreferencesChanged(); 5037 render_view_host->OnWebkitPreferencesChanged();
5035 } 5038 }
5036 5039
5037 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5040 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5038 JavaScriptDialogManager* dialog_manager) { 5041 JavaScriptDialogManager* dialog_manager) {
5039 dialog_manager_ = dialog_manager; 5042 dialog_manager_ = dialog_manager;
5040 } 5043 }
5041 5044
5042 } // namespace content 5045 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698