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

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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 OnDidFailProvisionalLoadWithError) 339 OnDidFailProvisionalLoadWithError)
337 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, 340 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError,
338 OnDidFailLoadWithError) 341 OnDidFailLoadWithError)
339 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, 342 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
340 OnDidCommitProvisionalLoad(msg)) 343 OnDidCommitProvisionalLoad(msg))
341 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) 344 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation)
342 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) 345 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
343 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, 346 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted,
344 OnDocumentOnLoadCompleted) 347 OnDocumentOnLoadCompleted)
345 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) 348 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK)
349 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent,
350 OnBeforeUnloadHandlersPresent)
351 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent,
352 OnUnloadHandlersPresent)
346 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) 353 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
347 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) 354 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
348 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, 355 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse,
349 OnJavaScriptExecuteResponse) 356 OnJavaScriptExecuteResponse)
350 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, 357 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage,
351 OnRunJavaScriptMessage) 358 OnRunJavaScriptMessage)
352 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, 359 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm,
353 OnRunBeforeUnloadConfirm) 360 OnRunBeforeUnloadConfirm)
354 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 361 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
355 OnDidAccessInitialDocument) 362 OnDidAccessInitialDocument)
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } 1001 }
995 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( 1002 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK(
996 frame_tree_node_); 1003 frame_tree_node_);
997 } 1004 }
998 1005
999 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { 1006 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const {
1000 return render_view_host_->is_waiting_for_close_ack_ || 1007 return render_view_host_->is_waiting_for_close_ack_ ||
1001 rfh_state_ == STATE_PENDING_SWAP_OUT; 1008 rfh_state_ == STATE_PENDING_SWAP_OUT;
1002 } 1009 }
1003 1010
1011 bool RenderFrameHostImpl::SuddenTerminationAllowed() const {
1012 return override_sudden_termination_status_ ||
1013 (!has_beforeunload_handlers_ && !has_unload_handlers_);
1014 }
1015
1004 void RenderFrameHostImpl::OnSwapOutACK() { 1016 void RenderFrameHostImpl::OnSwapOutACK() {
1005 OnSwappedOut(); 1017 OnSwappedOut();
1006 } 1018 }
1007 1019
1008 void RenderFrameHostImpl::OnSwappedOut() { 1020 void RenderFrameHostImpl::OnSwappedOut() {
1009 // Ignore spurious swap out ack. 1021 // Ignore spurious swap out ack.
1010 if (rfh_state_ != STATE_PENDING_SWAP_OUT) 1022 if (rfh_state_ != STATE_PENDING_SWAP_OUT)
1011 return; 1023 return;
1012 1024
1013 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); 1025 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 if (enter_fullscreen) 1270 if (enter_fullscreen)
1259 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); 1271 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin());
1260 else 1272 else
1261 delegate_->ExitFullscreenMode(); 1273 delegate_->ExitFullscreenMode();
1262 1274
1263 // The previous call might change the fullscreen state. We need to make sure 1275 // The previous call might change the fullscreen state. We need to make sure
1264 // the renderer is aware of that, which is done via the resize message. 1276 // the renderer is aware of that, which is done via the resize message.
1265 render_view_host_->WasResized(); 1277 render_view_host_->WasResized();
1266 } 1278 }
1267 1279
1280 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) {
1281 has_beforeunload_handlers_ = present;
1282 }
1283
1284 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) {
1285 has_unload_handlers_ = present;
1286 }
1287
1268 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1288 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1269 void RenderFrameHostImpl::OnShowPopup( 1289 void RenderFrameHostImpl::OnShowPopup(
1270 const FrameHostMsg_ShowPopup_Params& params) { 1290 const FrameHostMsg_ShowPopup_Params& params) {
1271 RenderViewHostDelegateView* view = 1291 RenderViewHostDelegateView* view =
1272 render_view_host_->delegate_->GetDelegateView(); 1292 render_view_host_->delegate_->GetDelegateView();
1273 if (view) { 1293 if (view) {
1274 view->ShowPopupMenu(this, 1294 view->ShowPopupMenu(this,
1275 params.bounds, 1295 params.bounds,
1276 params.item_height, 1296 params.item_height,
1277 params.item_font_size, 1297 params.item_font_size,
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1805 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1786 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1806 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1787 GetContentClient()->browser()->RegisterPermissionUsage( 1807 GetContentClient()->browser()->RegisterPermissionUsage(
1788 PERMISSION_GEOLOCATION, 1808 PERMISSION_GEOLOCATION,
1789 delegate_->GetAsWebContents(), 1809 delegate_->GetAsWebContents(),
1790 GetLastCommittedURL().GetOrigin(), 1810 GetLastCommittedURL().GetOrigin(),
1791 top_frame->GetLastCommittedURL().GetOrigin()); 1811 top_frame->GetLastCommittedURL().GetOrigin());
1792 } 1812 }
1793 1813
1794 } // namespace content 1814 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698