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

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

Issue 2384813002: Don't wait to close tabs waiting for JavaScript dialogs. (Closed)
Patch Set: fix Created 4 years, 2 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/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); 900 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this);
901 Send(new ViewMsg_Repaint(routing_id_, current_size_)); 901 Send(new ViewMsg_Repaint(routing_id_, current_size_));
902 return true; 902 return true;
903 } 903 }
904 904
905 void RenderWidgetHostImpl::StartHangMonitorTimeout( 905 void RenderWidgetHostImpl::StartHangMonitorTimeout(
906 base::TimeDelta delay, 906 base::TimeDelta delay,
907 RenderWidgetHostDelegate::RendererUnresponsiveType hang_monitor_reason) { 907 RenderWidgetHostDelegate::RendererUnresponsiveType hang_monitor_reason) {
908 if (!hang_monitor_timeout_) 908 if (!hang_monitor_timeout_)
909 return; 909 return;
910 hang_monitor_timeout_->Start(delay); 910
911 hang_monitor_reason_ = hang_monitor_reason; 911 hang_monitor_reason_ = hang_monitor_reason;
912
913 // If the renderer is known to be unresponsive, don't bother waiting for it.
914 if (known_unresponsive_renderer_count_ > 0)
915 hang_monitor_timeout_->Start(base::TimeDelta());
916 else
917 hang_monitor_timeout_->Start(delay);
912 } 918 }
913 919
914 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { 920 void RenderWidgetHostImpl::RestartHangMonitorTimeout() {
915 if (hang_monitor_timeout_) 921 if (!hang_monitor_timeout_)
922 return;
923
924 // If the renderer is known to be unresponsive, don't bother waiting for it.
925 if (known_unresponsive_renderer_count_ > 0)
926 hang_monitor_timeout_->Restart(base::TimeDelta());
927 else
916 hang_monitor_timeout_->Restart(hung_renderer_delay_); 928 hang_monitor_timeout_->Restart(hung_renderer_delay_);
917 } 929 }
918 930
919 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { 931 void RenderWidgetHostImpl::DisableHangMonitorForTesting() {
920 StopHangMonitorTimeout(); 932 StopHangMonitorTimeout();
921 hang_monitor_timeout_.reset(); 933 hang_monitor_timeout_.reset();
922 } 934 }
923 935
924 void RenderWidgetHostImpl::StopHangMonitorTimeout() { 936 void RenderWidgetHostImpl::StopHangMonitorTimeout() {
925 if (hang_monitor_timeout_) { 937 if (hang_monitor_timeout_) {
926 hang_monitor_timeout_->Stop(); 938 hang_monitor_timeout_->Stop();
927 hang_monitor_reason_ = 939 hang_monitor_reason_ =
928 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN; 940 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN;
929 } 941 }
930 RendererIsResponsive(); 942 RendererIsResponsive();
931 } 943 }
932 944
945 void RenderWidgetHostImpl::SetHangMonitorKnownUnresponsive(bool unresponsive) {
946 int count = unresponsive ? 1 : -1;
947 known_unresponsive_renderer_count_ += count;
948 DCHECK_GE(known_unresponsive_renderer_count_, 0);
949 }
950
933 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { 951 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() {
934 // It is possible for a compositor frame to arrive before the browser is 952 // It is possible for a compositor frame to arrive before the browser is
935 // notified about the page being committed, in which case no timer is 953 // notified about the page being committed, in which case no timer is
936 // necessary. 954 // necessary.
937 if (received_paint_after_load_) { 955 if (received_paint_after_load_) {
938 received_paint_after_load_ = false; 956 received_paint_after_load_ = false;
939 return; 957 return;
940 } 958 }
941 959
942 new_content_rendering_timeout_->Start(new_content_rendering_delay_); 960 new_content_rendering_timeout_->Start(new_content_rendering_delay_);
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2233 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2216 } 2234 }
2217 2235
2218 BrowserAccessibilityManager* 2236 BrowserAccessibilityManager*
2219 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2237 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2220 return delegate_ ? 2238 return delegate_ ?
2221 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2239 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2222 } 2240 }
2223 2241
2224 } // namespace content 2242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698