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

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, 11 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the 259 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
260 // RenderFrame. Currently this only happens in cross-site navigations. 260 // RenderFrame. Currently this only happens in cross-site navigations.
261 // PlzNavigate: this happens in every browser-initiated navigation that is not 261 // PlzNavigate: this happens in every browser-initiated navigation that is not
262 // same-page. 262 // same-page.
263 bool IsWaitingForBeforeUnloadACK() const; 263 bool IsWaitingForBeforeUnloadACK() const;
264 264
265 // Whether the RFH is waiting for an unload ACK from the renderer. 265 // Whether the RFH is waiting for an unload ACK from the renderer.
266 bool IsWaitingForUnloadACK() const; 266 bool IsWaitingForUnloadACK() const;
267 267
268 // Whether sudden termination is allowed for this frame. This is true if there
269 // are no BeforeUnload handlers or no Unload handlers registered for the
270 // frame, or it was overriden by the browser to be always true.
271 bool SuddenTerminationAllowed() const;
272
273 // Called by the browser to override (or not) the sudden termination status of
274 // the frame. When overriden, sudden termination is always allowed, even if
275 // would otherwise be prevented.
Charlie Reis 2015/01/29 23:20:41 nit: it would
clamy 2015/02/02 16:16:27 Done.
276 void set_override_sudden_termination_status(bool enabled) {
277 override_sudden_termination_status_ = enabled;
278 }
279
268 // Called when either the SwapOut request has been acknowledged or has timed 280 // Called when either the SwapOut request has been acknowledged or has timed
269 // out. 281 // out.
270 void OnSwappedOut(); 282 void OnSwappedOut();
271 283
272 // Whether this RenderFrameHost has been swapped out, such that the frame is 284 // Whether this RenderFrameHost has been swapped out, such that the frame is
273 // now rendered by a RenderFrameHost in a different process. 285 // now rendered by a RenderFrameHost in a different process.
274 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; } 286 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; }
275 287
276 // The current state of this RFH. 288 // The current state of this RFH.
277 RenderFrameHostImplState rfh_state() const { return rfh_state_; } 289 RenderFrameHostImplState rfh_state() const { return rfh_state_; }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, 487 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params,
476 const CommonNavigationParams& common_params); 488 const CommonNavigationParams& common_params);
477 void OnAccessibilityEvents( 489 void OnAccessibilityEvents(
478 const std::vector<AccessibilityHostMsg_EventParams>& params, 490 const std::vector<AccessibilityHostMsg_EventParams>& params,
479 int reset_token); 491 int reset_token);
480 void OnAccessibilityLocationChanges( 492 void OnAccessibilityLocationChanges(
481 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); 493 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
482 void OnAccessibilityFindInPageResult( 494 void OnAccessibilityFindInPageResult(
483 const AccessibilityHostMsg_FindInPageResultParams& params); 495 const AccessibilityHostMsg_FindInPageResultParams& params);
484 void OnToggleFullscreen(bool enter_fullscreen); 496 void OnToggleFullscreen(bool enter_fullscreen);
497 void OnBeforeUnloadHandlersPresent(bool present);
498 void OnUnloadHandlersPresent(bool present);
485 499
486 #if defined(OS_MACOSX) || defined(OS_ANDROID) 500 #if defined(OS_MACOSX) || defined(OS_ANDROID)
487 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); 501 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params);
488 void OnHidePopup(); 502 void OnHidePopup();
489 #endif 503 #endif
490 504
491 // Registers Mojo services that this frame host makes available. 505 // Registers Mojo services that this frame host makes available.
492 void RegisterMojoServices(); 506 void RegisterMojoServices();
493 507
494 // Updates the state of this RenderFrameHost and clears any waiting state 508 // Updates the state of this RenderFrameHost and clears any waiting state
(...skipping 18 matching lines...) Expand all
513 const std::map<int32, int>& node_to_browser_plugin_instance_id_map); 527 const std::map<int32, int>& node_to_browser_plugin_instance_id_map);
514 528
515 // Asserts that the given RenderFrameHostImpl is part of the same browser 529 // Asserts that the given RenderFrameHostImpl is part of the same browser
516 // context (and crashes if not), then returns whether the given frame is 530 // context (and crashes if not), then returns whether the given frame is
517 // part of the same site instance. 531 // part of the same site instance.
518 bool IsSameSiteInstance(RenderFrameHostImpl* other_render_frame_host); 532 bool IsSameSiteInstance(RenderFrameHostImpl* other_render_frame_host);
519 533
520 // Informs the content client that geolocation permissions were used. 534 // Informs the content client that geolocation permissions were used.
521 void DidUseGeolocationPermission(); 535 void DidUseGeolocationPermission();
522 536
537 // Handle a change in presence for one of the sudden termination disablers.
538 // Signals the RenderProcessHost if the sudden termination status for this
539 // frame changes.
540 void HandleSuddenTerminationDisablerPresenceChange(bool* disabler_presence,
Charlie Reis 2015/01/29 23:20:41 Don't forget to remove this, now that the implemen
clamy 2015/02/02 16:16:27 Done.
541 bool new_value);
542
523 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a 543 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
524 // refcount that calls Shutdown when it reaches zero. This allows each 544 // refcount that calls Shutdown when it reaches zero. This allows each
525 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring 545 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
526 // we have a RenderViewHost for each RenderFrameHost. 546 // we have a RenderViewHost for each RenderFrameHost.
527 // TODO(creis): RenderViewHost will eventually go away and be replaced with 547 // TODO(creis): RenderViewHost will eventually go away and be replaced with
528 // some form of page context. 548 // some form of page context.
529 RenderViewHostImpl* render_view_host_; 549 RenderViewHostImpl* render_view_host_;
530 550
531 RenderFrameHostDelegate* delegate_; 551 RenderFrameHostDelegate* delegate_;
532 552
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // We only buffer the params for a suspended navigation while this RFH is the 607 // We only buffer the params for a suspended navigation while this RFH is the
588 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever 608 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever
589 // be one suspended navigation, because RenderFrameHostManager will destroy 609 // be one suspended navigation, because RenderFrameHostManager will destroy
590 // the pending RenderFrameHost and create a new one if a second navigation 610 // the pending RenderFrameHost and create a new one if a second navigation
591 // occurs. 611 // occurs.
592 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_; 612 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_;
593 613
594 // When the last BeforeUnload message was sent. 614 // When the last BeforeUnload message was sent.
595 base::TimeTicks send_before_unload_start_time_; 615 base::TimeTicks send_before_unload_start_time_;
596 616
617 // Used to track whether sudden termination is allowed for this frame.
618 // has_beforeunload_handlers_ and has_unload_handlers_ are also used to avoid
619 // asking the renderer process to run BeforeUnload or Unload during
620 // navigation. The browser can set override_sudden_termination_status_ to
621 // true, in which case sudden termination will be allowed. This is used when a
622 // renderer executing BeforeUnload or Unload is unresponsive. All other values
623 // are modified based on IPCs received from the renderer.
624 bool has_beforeunload_handlers_;
625 bool has_unload_handlers_;
626 bool override_sudden_termination_status_;
627
597 // Set to true when there is a pending FrameMsg_ShouldClose message. This 628 // Set to true when there is a pending FrameMsg_ShouldClose message. This
598 // ensures we don't spam the renderer with multiple beforeunload requests. 629 // ensures we don't spam the renderer with multiple beforeunload requests.
599 // When either this value or IsWaitingForUnloadACK is true, the value of 630 // When either this value or IsWaitingForUnloadACK is true, the value of
600 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a 631 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
601 // cross-site transition or a tab close attempt. 632 // cross-site transition or a tab close attempt.
602 // TODO(clamy): Remove this boolean and add one more state to the state 633 // TODO(clamy): Remove this boolean and add one more state to the state
603 // machine. 634 // machine.
604 bool is_waiting_for_beforeunload_ack_; 635 bool is_waiting_for_beforeunload_ack_;
605 636
606 // Valid only when is_waiting_for_beforeunload_ack_ or 637 // Valid only when is_waiting_for_beforeunload_ack_ or
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 680
650 // NOTE: This must be the last member. 681 // NOTE: This must be the last member.
651 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 682 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
652 683
653 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 684 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
654 }; 685 };
655 686
656 } // namespace content 687 } // namespace content
657 688
658 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 689 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698