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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2384813002: Don't wait to close tabs waiting for JavaScript dialogs. (Closed)
Patch Set: better 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 // (if there was a cross-site "close" request pending when the user clicked 2377 // (if there was a cross-site "close" request pending when the user clicked
2378 // the close button). We want to keep the "for cross site" flag only if 2378 // the close button). We want to keep the "for cross site" flag only if
2379 // both the old and the new ones are also for cross site. 2379 // both the old and the new ones are also for cross site.
2380 unload_ack_is_for_navigation_ = 2380 unload_ack_is_for_navigation_ =
2381 unload_ack_is_for_navigation_ && for_navigation; 2381 unload_ack_is_for_navigation_ && for_navigation;
2382 } else { 2382 } else {
2383 // Start the hang monitor in case the renderer hangs in the beforeunload 2383 // Start the hang monitor in case the renderer hangs in the beforeunload
2384 // handler. 2384 // handler.
2385 is_waiting_for_beforeunload_ack_ = true; 2385 is_waiting_for_beforeunload_ack_ = true;
2386 unload_ack_is_for_navigation_ = for_navigation; 2386 unload_ack_is_for_navigation_ = for_navigation;
2387 // Increment the in-flight event count, to ensure that input events won't 2387 if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) {
2388 // cancel the timeout timer. 2388 // If there is a JavaScript dialog up, don't bother sending the renderer
2389 render_view_host_->GetWidget()->increment_in_flight_event_count(); 2389 // the unload event because it is known unresponsive, waiting for the
2390 render_view_host_->GetWidget()->StartHangMonitorTimeout( 2390 // reply from the dialog.
2391 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS), 2391 SimulateBeforeUnloadAck();
2392 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD); 2392 } else {
2393 send_before_unload_start_time_ = base::TimeTicks::Now(); 2393 // Increment the in-flight event count, to ensure that input events won't
2394 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); 2394 // cancel the timeout timer.
2395 render_view_host_->GetWidget()->increment_in_flight_event_count();
2396 render_view_host_->GetWidget()->StartHangMonitorTimeout(
2397 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS),
2398 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD);
2399 send_before_unload_start_time_ = base::TimeTicks::Now();
2400 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload));
2401 }
2395 } 2402 }
2396 } 2403 }
2397 2404
2398 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2405 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2399 DCHECK(is_waiting_for_beforeunload_ack_); 2406 DCHECK(is_waiting_for_beforeunload_ack_);
2400 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2407 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2401 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2408 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2402 } 2409 }
2403 2410
2404 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2411 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3117 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
3111 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3118 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
3112 return web_bluetooth_service_.get(); 3119 return web_bluetooth_service_.get();
3113 } 3120 }
3114 3121
3115 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3122 void RenderFrameHostImpl::DeleteWebBluetoothService() {
3116 web_bluetooth_service_.reset(); 3123 web_bluetooth_service_.reset();
3117 } 3124 }
3118 3125
3119 } // namespace content 3126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698