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

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 nits 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
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the 264 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
265 // RenderFrame. Currently this only happens in cross-site navigations. 265 // RenderFrame. Currently this only happens in cross-site navigations.
266 // PlzNavigate: this happens in every browser-initiated navigation that is not 266 // PlzNavigate: this happens in every browser-initiated navigation that is not
267 // same-page. 267 // same-page.
268 bool IsWaitingForBeforeUnloadACK() const; 268 bool IsWaitingForBeforeUnloadACK() const;
269 269
270 // Whether the RFH is waiting for an unload ACK from the renderer. 270 // Whether the RFH is waiting for an unload ACK from the renderer.
271 bool IsWaitingForUnloadACK() const; 271 bool IsWaitingForUnloadACK() const;
272 272
273 // Whether sudden termination is allowed for this frame. This is true if there
274 // are no BeforeUnload handlers or no Unload handlers registered for the
275 // frame, or it was overriden by the browser to be always true.
276 bool SuddenTerminationAllowed() const;
277
278 // Called by the browser to override (or not) the sudden termination status of
279 // the frame. When overriden, sudden termination is always allowed, even if
280 // it would otherwise be prevented.
281 void set_override_sudden_termination_status(bool enabled) {
282 override_sudden_termination_status_ = enabled;
283 }
284
273 // Called when either the SwapOut request has been acknowledged or has timed 285 // Called when either the SwapOut request has been acknowledged or has timed
274 // out. 286 // out.
275 void OnSwappedOut(); 287 void OnSwappedOut();
276 288
277 // Whether this RenderFrameHost has been swapped out, such that the frame is 289 // Whether this RenderFrameHost has been swapped out, such that the frame is
278 // now rendered by a RenderFrameHost in a different process. 290 // now rendered by a RenderFrameHost in a different process.
279 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; } 291 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; }
280 292
281 // The current state of this RFH. 293 // The current state of this RFH.
282 RenderFrameHostImplState rfh_state() const { return rfh_state_; } 294 RenderFrameHostImplState rfh_state() const { return rfh_state_; }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 const BeginNavigationParams& begin_params, 501 const BeginNavigationParams& begin_params,
490 scoped_refptr<ResourceRequestBody> body); 502 scoped_refptr<ResourceRequestBody> body);
491 void OnAccessibilityEvents( 503 void OnAccessibilityEvents(
492 const std::vector<AccessibilityHostMsg_EventParams>& params, 504 const std::vector<AccessibilityHostMsg_EventParams>& params,
493 int reset_token); 505 int reset_token);
494 void OnAccessibilityLocationChanges( 506 void OnAccessibilityLocationChanges(
495 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); 507 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
496 void OnAccessibilityFindInPageResult( 508 void OnAccessibilityFindInPageResult(
497 const AccessibilityHostMsg_FindInPageResultParams& params); 509 const AccessibilityHostMsg_FindInPageResultParams& params);
498 void OnToggleFullscreen(bool enter_fullscreen); 510 void OnToggleFullscreen(bool enter_fullscreen);
511 void OnBeforeUnloadHandlersPresent(bool present);
512 void OnUnloadHandlersPresent(bool present);
499 513
500 #if defined(OS_MACOSX) || defined(OS_ANDROID) 514 #if defined(OS_MACOSX) || defined(OS_ANDROID)
501 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); 515 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params);
502 void OnHidePopup(); 516 void OnHidePopup();
503 #endif 517 #endif
504 518
505 // Registers Mojo services that this frame host makes available. 519 // Registers Mojo services that this frame host makes available.
506 void RegisterMojoServices(); 520 void RegisterMojoServices();
507 521
508 // Updates the state of this RenderFrameHost and clears any waiting state 522 // Updates the state of this RenderFrameHost and clears any waiting state
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // We only buffer the params for a suspended navigation while this RFH is the 628 // We only buffer the params for a suspended navigation while this RFH is the
615 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever 629 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever
616 // be one suspended navigation, because RenderFrameHostManager will destroy 630 // be one suspended navigation, because RenderFrameHostManager will destroy
617 // the pending RenderFrameHost and create a new one if a second navigation 631 // the pending RenderFrameHost and create a new one if a second navigation
618 // occurs. 632 // occurs.
619 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_; 633 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_;
620 634
621 // When the last BeforeUnload message was sent. 635 // When the last BeforeUnload message was sent.
622 base::TimeTicks send_before_unload_start_time_; 636 base::TimeTicks send_before_unload_start_time_;
623 637
638 // Used to track whether sudden termination is allowed for this frame.
639 // has_beforeunload_handlers_ and has_unload_handlers_ are also used to avoid
640 // asking the renderer process to run BeforeUnload or Unload during
641 // navigation. The browser can set override_sudden_termination_status_ to
642 // true, in which case sudden termination will be allowed. This is used when a
643 // renderer executing BeforeUnload or Unload is unresponsive. All other values
644 // are modified based on IPCs received from the renderer.
645 bool has_beforeunload_handlers_;
646 bool has_unload_handlers_;
647 bool override_sudden_termination_status_;
648
624 // Set to true when there is a pending FrameMsg_ShouldClose message. This 649 // Set to true when there is a pending FrameMsg_ShouldClose message. This
625 // ensures we don't spam the renderer with multiple beforeunload requests. 650 // ensures we don't spam the renderer with multiple beforeunload requests.
626 // When either this value or IsWaitingForUnloadACK is true, the value of 651 // When either this value or IsWaitingForUnloadACK is true, the value of
627 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a 652 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
628 // cross-site transition or a tab close attempt. 653 // cross-site transition or a tab close attempt.
629 // TODO(clamy): Remove this boolean and add one more state to the state 654 // TODO(clamy): Remove this boolean and add one more state to the state
630 // machine. 655 // machine.
631 bool is_waiting_for_beforeunload_ack_; 656 bool is_waiting_for_beforeunload_ack_;
632 657
633 // Valid only when is_waiting_for_beforeunload_ack_ or 658 // Valid only when is_waiting_for_beforeunload_ack_ or
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 703
679 // NOTE: This must be the last member. 704 // NOTE: This must be the last member.
680 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 705 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
681 706
682 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 707 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
683 }; 708 };
684 709
685 } // namespace content 710 } // namespace content
686 711
687 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 712 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698