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

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

Issue 1890493002: PlzNavigate: properly execute BeforeUnload on renderer initiated navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fixed issue with layout test Created 4 years, 6 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 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 frame_tree_node_->navigator()->RequestOpenURL( 2157 frame_tree_node_->navigator()->RequestOpenURL(
2158 this, validated_url, source_site_instance, params.referrer, 2158 this, validated_url, source_site_instance, params.referrer,
2159 params.disposition, params.should_replace_current_entry, 2159 params.disposition, params.should_replace_current_entry,
2160 params.user_gesture); 2160 params.user_gesture);
2161 } 2161 }
2162 2162
2163 void RenderFrameHostImpl::Stop() { 2163 void RenderFrameHostImpl::Stop() {
2164 Send(new FrameMsg_Stop(routing_id_)); 2164 Send(new FrameMsg_Stop(routing_id_));
2165 } 2165 }
2166 2166
2167 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { 2167 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation,
2168 bool is_reload) {
2169 DCHECK(for_navigation || !is_reload);
2170
2168 // TODO(creis): Support beforeunload on subframes. For now just pretend that 2171 // TODO(creis): Support beforeunload on subframes. For now just pretend that
2169 // the handler ran and allowed the navigation to proceed. 2172 // the handler ran and allowed the navigation to proceed.
2170 if (!ShouldDispatchBeforeUnload()) { 2173 if (!ShouldDispatchBeforeUnload()) {
2171 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation)); 2174 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation));
2172 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 2175 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
2173 for_navigation, true, base::TimeTicks::Now()); 2176 for_navigation, true, base::TimeTicks::Now());
2174 return; 2177 return;
2175 } 2178 }
2176 TRACE_EVENT_ASYNC_BEGIN1("navigation", "RenderFrameHostImpl BeforeUnload", 2179 TRACE_EVENT_ASYNC_BEGIN1("navigation", "RenderFrameHostImpl BeforeUnload",
2177 this, "&RenderFrameHostImpl", (void*)this); 2180 this, "&RenderFrameHostImpl", (void*)this);
(...skipping 14 matching lines...) Expand all
2192 // Start the hang monitor in case the renderer hangs in the beforeunload 2195 // Start the hang monitor in case the renderer hangs in the beforeunload
2193 // handler. 2196 // handler.
2194 is_waiting_for_beforeunload_ack_ = true; 2197 is_waiting_for_beforeunload_ack_ = true;
2195 unload_ack_is_for_navigation_ = for_navigation; 2198 unload_ack_is_for_navigation_ = for_navigation;
2196 // Increment the in-flight event count, to ensure that input events won't 2199 // Increment the in-flight event count, to ensure that input events won't
2197 // cancel the timeout timer. 2200 // cancel the timeout timer.
2198 render_view_host_->GetWidget()->increment_in_flight_event_count(); 2201 render_view_host_->GetWidget()->increment_in_flight_event_count();
2199 render_view_host_->GetWidget()->StartHangMonitorTimeout( 2202 render_view_host_->GetWidget()->StartHangMonitorTimeout(
2200 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); 2203 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS));
2201 send_before_unload_start_time_ = base::TimeTicks::Now(); 2204 send_before_unload_start_time_ = base::TimeTicks::Now();
2202 Send(new FrameMsg_BeforeUnload(routing_id_)); 2205 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload));
2203 } 2206 }
2204 } 2207 }
2205 2208
2206 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2209 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2207 DCHECK(is_waiting_for_beforeunload_ack_); 2210 DCHECK(is_waiting_for_beforeunload_ack_);
2208 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2211 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2209 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2212 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2210 } 2213 }
2211 2214
2212 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2215 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 // handler after it's destroyed so it can't run after the RFHI is destroyed. 2852 // handler after it's destroyed so it can't run after the RFHI is destroyed.
2850 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 2853 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
2851 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 2854 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
2852 } 2855 }
2853 2856
2854 void RenderFrameHostImpl::DeleteWebBluetoothService() { 2857 void RenderFrameHostImpl::DeleteWebBluetoothService() {
2855 web_bluetooth_service_.reset(); 2858 web_bluetooth_service_.reset();
2856 } 2859 }
2857 2860
2858 } // namespace content 2861 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698