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

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

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 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the 260 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
261 // RenderFrame. Currently this only happens in cross-site navigations. 261 // RenderFrame. Currently this only happens in cross-site navigations.
262 // PlzNavigate: this happens in every browser-initiated navigation that is not 262 // PlzNavigate: this happens in every browser-initiated navigation that is not
263 // same-page. 263 // same-page.
264 bool IsWaitingForBeforeUnloadACK() const; 264 bool IsWaitingForBeforeUnloadACK() const;
265 265
266 // Whether the RFH is waiting for an unload ACK from the renderer. 266 // Whether the RFH is waiting for an unload ACK from the renderer.
267 bool IsWaitingForUnloadACK() const; 267 bool IsWaitingForUnloadACK() const;
268 268
269 // Whether sudden termination is allowed for this frame. This is true if there
270 // are no BeforeUnload handlers or no Unload handlers registered for the
271 // frame, or it was overriden by the browser to be always true.
272 bool SuddenTerminationAllowed() const;
273
274 // Called by the browser to override (or not) the sudden termination status of
275 // the frame. When overriden, sudden termination is always allowed, even if
276 // it would otherwise be prevented.
277 void set_override_sudden_termination_status(bool enabled) {
278 override_sudden_termination_status_ = enabled;
279 }
280
269 // Called when either the SwapOut request has been acknowledged or has timed 281 // Called when either the SwapOut request has been acknowledged or has timed
270 // out. 282 // out.
271 void OnSwappedOut(); 283 void OnSwappedOut();
272 284
273 // Whether this RenderFrameHost has been swapped out, such that the frame is 285 // Whether this RenderFrameHost has been swapped out, such that the frame is
274 // now rendered by a RenderFrameHost in a different process. 286 // now rendered by a RenderFrameHost in a different process.
275 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; } 287 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; }
276 288
277 // The current state of this RFH. 289 // The current state of this RFH.
278 RenderFrameHostImplState rfh_state() const { return rfh_state_; } 290 RenderFrameHostImplState rfh_state() const { return rfh_state_; }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, 494 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params,
483 const CommonNavigationParams& common_params); 495 const CommonNavigationParams& common_params);
484 void OnAccessibilityEvents( 496 void OnAccessibilityEvents(
485 const std::vector<AccessibilityHostMsg_EventParams>& params, 497 const std::vector<AccessibilityHostMsg_EventParams>& params,
486 int reset_token); 498 int reset_token);
487 void OnAccessibilityLocationChanges( 499 void OnAccessibilityLocationChanges(
488 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); 500 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
489 void OnAccessibilityFindInPageResult( 501 void OnAccessibilityFindInPageResult(
490 const AccessibilityHostMsg_FindInPageResultParams& params); 502 const AccessibilityHostMsg_FindInPageResultParams& params);
491 void OnToggleFullscreen(bool enter_fullscreen); 503 void OnToggleFullscreen(bool enter_fullscreen);
504 void OnBeforeUnloadHandlersPresent(bool present);
505 void OnUnloadHandlersPresent(bool present);
492 506
493 #if defined(OS_MACOSX) || defined(OS_ANDROID) 507 #if defined(OS_MACOSX) || defined(OS_ANDROID)
494 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); 508 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params);
495 void OnHidePopup(); 509 void OnHidePopup();
496 #endif 510 #endif
497 511
498 // Registers Mojo services that this frame host makes available. 512 // Registers Mojo services that this frame host makes available.
499 void RegisterMojoServices(); 513 void RegisterMojoServices();
500 514
501 // Updates the state of this RenderFrameHost and clears any waiting state 515 // Updates the state of this RenderFrameHost and clears any waiting state
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // We only buffer the params for a suspended navigation while this RFH is the 619 // We only buffer the params for a suspended navigation while this RFH is the
606 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever 620 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever
607 // be one suspended navigation, because RenderFrameHostManager will destroy 621 // be one suspended navigation, because RenderFrameHostManager will destroy
608 // the pending RenderFrameHost and create a new one if a second navigation 622 // the pending RenderFrameHost and create a new one if a second navigation
609 // occurs. 623 // occurs.
610 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_; 624 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_;
611 625
612 // When the last BeforeUnload message was sent. 626 // When the last BeforeUnload message was sent.
613 base::TimeTicks send_before_unload_start_time_; 627 base::TimeTicks send_before_unload_start_time_;
614 628
629 // Used to track whether sudden termination is allowed for this frame.
630 // has_beforeunload_handlers_ and has_unload_handlers_ are also used to avoid
631 // asking the renderer process to run BeforeUnload or Unload during
632 // navigation. The browser can set override_sudden_termination_status_ to
633 // true, in which case sudden termination will be allowed. This is used when a
634 // renderer executing BeforeUnload or Unload is unresponsive. All other values
635 // are modified based on IPCs received from the renderer.
636 bool has_beforeunload_handlers_;
637 bool has_unload_handlers_;
638 bool override_sudden_termination_status_;
639
615 // Set to true when there is a pending FrameMsg_ShouldClose message. This 640 // Set to true when there is a pending FrameMsg_ShouldClose message. This
616 // ensures we don't spam the renderer with multiple beforeunload requests. 641 // ensures we don't spam the renderer with multiple beforeunload requests.
617 // When either this value or IsWaitingForUnloadACK is true, the value of 642 // When either this value or IsWaitingForUnloadACK is true, the value of
618 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a 643 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
619 // cross-site transition or a tab close attempt. 644 // cross-site transition or a tab close attempt.
620 // TODO(clamy): Remove this boolean and add one more state to the state 645 // TODO(clamy): Remove this boolean and add one more state to the state
621 // machine. 646 // machine.
622 bool is_waiting_for_beforeunload_ack_; 647 bool is_waiting_for_beforeunload_ack_;
623 648
624 // Valid only when is_waiting_for_beforeunload_ack_ or 649 // Valid only when is_waiting_for_beforeunload_ack_ or
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 692
668 // NOTE: This must be the last member. 693 // NOTE: This must be the last member.
669 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 694 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
670 695
671 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 696 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
672 }; 697 };
673 698
674 } // namespace content 699 } // namespace content
675 700
676 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 701 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698