OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 struct ResourceResponse; | 96 struct ResourceResponse; |
97 | 97 |
98 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost, | 98 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost, |
99 public BrowserAccessibilityDelegate, | 99 public BrowserAccessibilityDelegate, |
100 public SiteInstanceImpl::Observer { | 100 public SiteInstanceImpl::Observer { |
101 public: | 101 public: |
102 using AXTreeSnapshotCallback = | 102 using AXTreeSnapshotCallback = |
103 base::Callback<void( | 103 base::Callback<void( |
104 const ui::AXTreeUpdate&)>; | 104 const ui::AXTreeUpdate&)>; |
105 | 105 |
106 // Keeps track of the state of the RenderFrameHostImpl, particularly with | |
107 // respect to swap out. | |
108 enum RenderFrameHostImplState { | |
109 // The standard state for a RFH handling the communication with an active | |
110 // RenderFrame. | |
111 STATE_DEFAULT = 0, | |
112 // The RFH has not received the SwapOutACK yet, but the new page has | |
113 // committed in a different RFH. Upon reception of the SwapOutACK, the RFH | |
114 // will be deleted. | |
115 STATE_PENDING_SWAP_OUT, | |
116 }; | |
117 // Helper function to determine whether the RFH state should contribute to the | |
118 // number of active frames of a SiteInstance or not. | |
119 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state); | |
120 | |
121 // An accessibility reset is only allowed to prevent very rare corner cases | 106 // An accessibility reset is only allowed to prevent very rare corner cases |
122 // or race conditions where the browser and renderer get out of sync. If | 107 // or race conditions where the browser and renderer get out of sync. If |
123 // this happens more than this many times, kill the renderer. | 108 // this happens more than this many times, kill the renderer. |
124 static const int kMaxAccessibilityResets = 5; | 109 static const int kMaxAccessibilityResets = 5; |
125 | 110 |
126 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 111 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
127 static RenderFrameHostImpl* FromAXTreeID( | 112 static RenderFrameHostImpl* FromAXTreeID( |
128 AXTreeIDRegistry::AXTreeID ax_tree_id); | 113 AXTreeIDRegistry::AXTreeID ax_tree_id); |
129 | 114 |
130 ~RenderFrameHostImpl() override; | 115 ~RenderFrameHostImpl() override; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return is_waiting_for_beforeunload_ack_; | 337 return is_waiting_for_beforeunload_ack_; |
353 } | 338 } |
354 | 339 |
355 // Whether the RFH is waiting for an unload ACK from the renderer. | 340 // Whether the RFH is waiting for an unload ACK from the renderer. |
356 bool IsWaitingForUnloadACK() const; | 341 bool IsWaitingForUnloadACK() const; |
357 | 342 |
358 // Called when either the SwapOut request has been acknowledged or has timed | 343 // Called when either the SwapOut request has been acknowledged or has timed |
359 // out. | 344 // out. |
360 void OnSwappedOut(); | 345 void OnSwappedOut(); |
361 | 346 |
362 // The current state of this RFH. | 347 // This method returns true from the time this RenderFrameHost is created |
363 RenderFrameHostImplState rfh_state() const { return rfh_state_; } | 348 // until SwapOut is called, at which point it is pending deletion. |
| 349 bool is_active() { return !is_waiting_for_swapout_ack_; } |
364 | 350 |
365 // Sends the given navigation message. Use this rather than sending it | 351 // Sends the given navigation message. Use this rather than sending it |
366 // yourself since this does the internal bookkeeping described below. This | 352 // yourself since this does the internal bookkeeping described below. This |
367 // function takes ownership of the provided message pointer. | 353 // function takes ownership of the provided message pointer. |
368 // | 354 // |
369 // If a cross-site request is in progress, we may be suspended while waiting | 355 // If a cross-site request is in progress, we may be suspended while waiting |
370 // for the onbeforeunload handler, so this function might buffer the message | 356 // for the onbeforeunload handler, so this function might buffer the message |
371 // rather than sending it. | 357 // rather than sending it. |
372 void Navigate(const CommonNavigationParams& common_params, | 358 void Navigate(const CommonNavigationParams& common_params, |
373 const StartNavigationParams& start_params, | 359 const StartNavigationParams& start_params, |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 const std::set<std::string>& digests_of_uris_of_serialized_resources); | 663 const std::set<std::string>& digests_of_uris_of_serialized_resources); |
678 | 664 |
679 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 665 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
680 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); | 666 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); |
681 void OnHidePopup(); | 667 void OnHidePopup(); |
682 #endif | 668 #endif |
683 | 669 |
684 // Registers Mojo services that this frame host makes available. | 670 // Registers Mojo services that this frame host makes available. |
685 void RegisterMojoServices(); | 671 void RegisterMojoServices(); |
686 | 672 |
687 // Updates the state of this RenderFrameHost and clears any waiting state | 673 // Resets any waiting state of this RenderFrameHost that is no longer |
688 // that is no longer relevant. | 674 // relevant. |
689 void SetState(RenderFrameHostImplState rfh_state); | 675 void ResetWaitingState(); |
690 | 676 |
691 // Returns whether the given URL is allowed to commit in the current process. | 677 // Returns whether the given URL is allowed to commit in the current process. |
692 // This is a more conservative check than RenderProcessHost::FilterURL, since | 678 // This is a more conservative check than RenderProcessHost::FilterURL, since |
693 // it will be used to kill processes that commit unauthorized URLs. | 679 // it will be used to kill processes that commit unauthorized URLs. |
694 bool CanCommitURL(const GURL& url); | 680 bool CanCommitURL(const GURL& url); |
695 | 681 |
696 // Returns whether the given origin is allowed to commit in the current | 682 // Returns whether the given origin is allowed to commit in the current |
697 // RenderFrameHost. The |url| is used to ensure it matches the origin in cases | 683 // RenderFrameHost. The |url| is used to ensure it matches the origin in cases |
698 // where it is applicable. This is a more conservative check than | 684 // where it is applicable. This is a more conservative check than |
699 // RenderProcessHost::FilterURL, since it will be used to kill processes that | 685 // RenderProcessHost::FilterURL, since it will be used to kill processes that |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // RenderFrameHosts that need management of the rendering and input events | 809 // RenderFrameHosts that need management of the rendering and input events |
824 // for their frame subtrees require RenderWidgetHosts. This typically | 810 // for their frame subtrees require RenderWidgetHosts. This typically |
825 // means frames that are rendered in different processes from their parent | 811 // means frames that are rendered in different processes from their parent |
826 // frames. | 812 // frames. |
827 // TODO(kenrb): Later this will also be used on the top-level frame, when | 813 // TODO(kenrb): Later this will also be used on the top-level frame, when |
828 // RenderFrameHost owns its RenderViewHost. | 814 // RenderFrameHost owns its RenderViewHost. |
829 RenderWidgetHostImpl* render_widget_host_; | 815 RenderWidgetHostImpl* render_widget_host_; |
830 | 816 |
831 int routing_id_; | 817 int routing_id_; |
832 | 818 |
833 // The current state of this RenderFrameHost. | 819 // Boolean indicating whether this RenderFrameHost is being actively used or |
834 RenderFrameHostImplState rfh_state_; | 820 // is waiting for FrameHostMsg_SwapOut_ACK and thus pending deletion. |
| 821 bool is_waiting_for_swapout_ack_; |
835 | 822 |
836 // Tracks whether the RenderFrame for this RenderFrameHost has been created in | 823 // Tracks whether the RenderFrame for this RenderFrameHost has been created in |
837 // the renderer process. Currently only used for subframes. | 824 // the renderer process. Currently only used for subframes. |
838 // TODO(creis): Use this for main frames as well when RVH goes away. | 825 // TODO(creis): Use this for main frames as well when RVH goes away. |
839 bool render_frame_created_; | 826 bool render_frame_created_; |
840 | 827 |
841 // Whether we should buffer outgoing Navigate messages rather than sending | 828 // Whether we should buffer outgoing Navigate messages rather than sending |
842 // them. This will be true when a RenderFrameHost is created for a cross-site | 829 // them. This will be true when a RenderFrameHost is created for a cross-site |
843 // request, until we hear back from the onbeforeunload handler of the old | 830 // request, until we hear back from the onbeforeunload handler of the old |
844 // RenderFrameHost. | 831 // RenderFrameHost. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 963 |
977 // NOTE: This must be the last member. | 964 // NOTE: This must be the last member. |
978 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 965 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
979 | 966 |
980 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 967 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
981 }; | 968 }; |
982 | 969 |
983 } // namespace content | 970 } // namespace content |
984 | 971 |
985 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 972 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |