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

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

Issue 857213003: Refactor sudden termination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Charlie's comments Created 5 years, 10 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 delegate_(delegate), 136 delegate_(delegate),
137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), 137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)),
138 process_(site_instance->GetProcess()), 138 process_(site_instance->GetProcess()),
139 cross_process_frame_connector_(NULL), 139 cross_process_frame_connector_(NULL),
140 render_frame_proxy_host_(NULL), 140 render_frame_proxy_host_(NULL),
141 frame_tree_(frame_tree), 141 frame_tree_(frame_tree),
142 frame_tree_node_(frame_tree_node), 142 frame_tree_node_(frame_tree_node),
143 routing_id_(routing_id), 143 routing_id_(routing_id),
144 render_frame_created_(false), 144 render_frame_created_(false),
145 navigations_suspended_(false), 145 navigations_suspended_(false),
146 has_beforeunload_handlers_(false),
147 has_unload_handlers_(false),
148 override_sudden_termination_status_(false),
146 is_waiting_for_beforeunload_ack_(false), 149 is_waiting_for_beforeunload_ack_(false),
147 unload_ack_is_for_cross_site_transition_(false), 150 unload_ack_is_for_cross_site_transition_(false),
148 accessibility_reset_token_(0), 151 accessibility_reset_token_(0),
149 accessibility_reset_count_(0), 152 accessibility_reset_count_(0),
150 no_create_browser_accessibility_manager_for_testing_(false), 153 no_create_browser_accessibility_manager_for_testing_(false),
151 weak_ptr_factory_(this) { 154 weak_ptr_factory_(this) {
152 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); 155 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
153 bool hidden = !!(flags & CREATE_RF_HIDDEN); 156 bool hidden = !!(flags & CREATE_RF_HIDDEN);
154 frame_tree_->RegisterRenderFrameHost(this); 157 frame_tree_->RegisterRenderFrameHost(this);
155 GetProcess()->AddRoute(routing_id_, this); 158 GetProcess()->AddRoute(routing_id_, this);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 OnDidFailProvisionalLoadWithError) 337 OnDidFailProvisionalLoadWithError)
335 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, 338 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError,
336 OnDidFailLoadWithError) 339 OnDidFailLoadWithError)
337 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, 340 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
338 OnDidCommitProvisionalLoad(msg)) 341 OnDidCommitProvisionalLoad(msg))
339 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) 342 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation)
340 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) 343 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
341 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, 344 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted,
342 OnDocumentOnLoadCompleted) 345 OnDocumentOnLoadCompleted)
343 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) 346 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK)
347 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent,
348 OnBeforeUnloadHandlersPresent)
349 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent,
350 OnUnloadHandlersPresent)
344 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) 351 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
345 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) 352 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
346 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, 353 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse,
347 OnJavaScriptExecuteResponse) 354 OnJavaScriptExecuteResponse)
348 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, 355 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage,
349 OnRunJavaScriptMessage) 356 OnRunJavaScriptMessage)
350 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, 357 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm,
351 OnRunBeforeUnloadConfirm) 358 OnRunBeforeUnloadConfirm)
352 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 359 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
353 OnDidAccessInitialDocument) 360 OnDidAccessInitialDocument)
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 } 991 }
985 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( 992 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK(
986 frame_tree_node_); 993 frame_tree_node_);
987 } 994 }
988 995
989 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { 996 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const {
990 return render_view_host_->is_waiting_for_close_ack_ || 997 return render_view_host_->is_waiting_for_close_ack_ ||
991 rfh_state_ == STATE_PENDING_SWAP_OUT; 998 rfh_state_ == STATE_PENDING_SWAP_OUT;
992 } 999 }
993 1000
1001 bool RenderFrameHostImpl::SuddenTerminationAllowed() const {
1002 return override_sudden_termination_status_ ||
1003 (!has_beforeunload_handlers_ && !has_unload_handlers_);
1004 }
1005
994 void RenderFrameHostImpl::OnSwapOutACK() { 1006 void RenderFrameHostImpl::OnSwapOutACK() {
995 OnSwappedOut(); 1007 OnSwappedOut();
996 } 1008 }
997 1009
998 void RenderFrameHostImpl::OnSwappedOut() { 1010 void RenderFrameHostImpl::OnSwappedOut() {
999 // Ignore spurious swap out ack. 1011 // Ignore spurious swap out ack.
1000 if (rfh_state_ != STATE_PENDING_SWAP_OUT) 1012 if (rfh_state_ != STATE_PENDING_SWAP_OUT)
1001 return; 1013 return;
1002 1014
1003 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); 1015 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 if (enter_fullscreen) 1260 if (enter_fullscreen)
1249 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); 1261 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin());
1250 else 1262 else
1251 delegate_->ExitFullscreenMode(); 1263 delegate_->ExitFullscreenMode();
1252 1264
1253 // The previous call might change the fullscreen state. We need to make sure 1265 // The previous call might change the fullscreen state. We need to make sure
1254 // the renderer is aware of that, which is done via the resize message. 1266 // the renderer is aware of that, which is done via the resize message.
1255 render_view_host_->WasResized(); 1267 render_view_host_->WasResized();
1256 } 1268 }
1257 1269
1270 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) {
1271 has_beforeunload_handlers_ = present;
1272 }
1273
1274 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) {
1275 has_unload_handlers_ = present;
1276 }
1277
1258 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1278 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1259 void RenderFrameHostImpl::OnShowPopup( 1279 void RenderFrameHostImpl::OnShowPopup(
1260 const FrameHostMsg_ShowPopup_Params& params) { 1280 const FrameHostMsg_ShowPopup_Params& params) {
1261 RenderViewHostDelegateView* view = 1281 RenderViewHostDelegateView* view =
1262 render_view_host_->delegate_->GetDelegateView(); 1282 render_view_host_->delegate_->GetDelegateView();
1263 if (view) { 1283 if (view) {
1264 view->ShowPopupMenu(this, 1284 view->ShowPopupMenu(this,
1265 params.bounds, 1285 params.bounds,
1266 params.item_height, 1286 params.item_height,
1267 params.item_font_size, 1287 params.item_font_size,
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1791 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1772 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1792 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1773 GetContentClient()->browser()->RegisterPermissionUsage( 1793 GetContentClient()->browser()->RegisterPermissionUsage(
1774 PERMISSION_GEOLOCATION, 1794 PERMISSION_GEOLOCATION,
1775 delegate_->GetAsWebContents(), 1795 delegate_->GetAsWebContents(),
1776 GetLastCommittedURL().GetOrigin(), 1796 GetLastCommittedURL().GetOrigin(),
1777 top_frame->GetLastCommittedURL().GetOrigin()); 1797 top_frame->GetLastCommittedURL().GetOrigin());
1778 } 1798 }
1779 1799
1780 } // namespace content 1800 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698