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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 struct ResourceResponse; | 89 struct ResourceResponse; |
90 | 90 |
91 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost, | 91 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost, |
92 public BrowserAccessibilityDelegate, | 92 public BrowserAccessibilityDelegate, |
93 public SiteInstanceImpl::Observer { | 93 public SiteInstanceImpl::Observer { |
94 public: | 94 public: |
95 using AXTreeSnapshotCallback = | 95 using AXTreeSnapshotCallback = |
96 base::Callback<void( | 96 base::Callback<void( |
97 const ui::AXTreeUpdate&)>; | 97 const ui::AXTreeUpdate&)>; |
98 | 98 |
99 // Keeps track of the state of the RenderFrameHostImpl, particularly with | |
100 // respect to swap out. | |
101 enum RenderFrameHostImplState { | |
102 // The standard state for a RFH handling the communication with an active | |
103 // RenderFrame. | |
104 STATE_DEFAULT = 0, | |
105 // The RFH has not received the SwapOutACK yet, but the new page has | |
106 // committed in a different RFH. Upon reception of the SwapOutACK, the RFH | |
107 // will be deleted. | |
108 STATE_PENDING_SWAP_OUT, | |
109 }; | |
110 // Helper function to determine whether the RFH state should contribute to the | |
111 // number of active frames of a SiteInstance or not. | |
112 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state); | |
113 | |
114 // An accessibility reset is only allowed to prevent very rare corner cases | 99 // An accessibility reset is only allowed to prevent very rare corner cases |
115 // or race conditions where the browser and renderer get out of sync. If | 100 // or race conditions where the browser and renderer get out of sync. If |
116 // this happens more than this many times, kill the renderer. | 101 // this happens more than this many times, kill the renderer. |
117 static const int kMaxAccessibilityResets = 5; | 102 static const int kMaxAccessibilityResets = 5; |
118 | 103 |
119 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 104 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
120 static RenderFrameHostImpl* FromAXTreeID( | 105 static RenderFrameHostImpl* FromAXTreeID( |
121 AXTreeIDRegistry::AXTreeID ax_tree_id); | 106 AXTreeIDRegistry::AXTreeID ax_tree_id); |
122 | 107 |
123 ~RenderFrameHostImpl() override; | 108 ~RenderFrameHostImpl() override; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 return is_waiting_for_beforeunload_ack_; | 327 return is_waiting_for_beforeunload_ack_; |
343 } | 328 } |
344 | 329 |
345 // Whether the RFH is waiting for an unload ACK from the renderer. | 330 // Whether the RFH is waiting for an unload ACK from the renderer. |
346 bool IsWaitingForUnloadACK() const; | 331 bool IsWaitingForUnloadACK() const; |
347 | 332 |
348 // Called when either the SwapOut request has been acknowledged or has timed | 333 // Called when either the SwapOut request has been acknowledged or has timed |
349 // out. | 334 // out. |
350 void OnSwappedOut(); | 335 void OnSwappedOut(); |
351 | 336 |
352 // The current state of this RFH. | 337 // The current state of this RFH. |
Charlie Reis
2016/04/04 17:16:36
This comment needs to be updated to say precisely
nasko
2016/04/08 17:42:07
Done.
| |
353 RenderFrameHostImplState rfh_state() const { return rfh_state_; } | 338 bool is_active() { return !is_waiting_for_swapout_ack_; } |
354 | 339 |
355 // Sends the given navigation message. Use this rather than sending it | 340 // Sends the given navigation message. Use this rather than sending it |
356 // yourself since this does the internal bookkeeping described below. This | 341 // yourself since this does the internal bookkeeping described below. This |
357 // function takes ownership of the provided message pointer. | 342 // function takes ownership of the provided message pointer. |
358 // | 343 // |
359 // If a cross-site request is in progress, we may be suspended while waiting | 344 // If a cross-site request is in progress, we may be suspended while waiting |
360 // for the onbeforeunload handler, so this function might buffer the message | 345 // for the onbeforeunload handler, so this function might buffer the message |
361 // rather than sending it. | 346 // rather than sending it. |
362 void Navigate(const CommonNavigationParams& common_params, | 347 void Navigate(const CommonNavigationParams& common_params, |
363 const StartNavigationParams& start_params, | 348 const StartNavigationParams& start_params, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 const std::set<std::string>& digests_of_uris_of_serialized_resources); | 637 const std::set<std::string>& digests_of_uris_of_serialized_resources); |
653 | 638 |
654 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 639 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
655 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); | 640 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); |
656 void OnHidePopup(); | 641 void OnHidePopup(); |
657 #endif | 642 #endif |
658 | 643 |
659 // Registers Mojo services that this frame host makes available. | 644 // Registers Mojo services that this frame host makes available. |
660 void RegisterMojoServices(); | 645 void RegisterMojoServices(); |
661 | 646 |
662 // Updates the state of this RenderFrameHost and clears any waiting state | 647 // Resets any waiting state of this RenderFrameHost that is no longer |
663 // that is no longer relevant. | 648 // relevant. |
664 void SetState(RenderFrameHostImplState rfh_state); | 649 void ResetWaitingState(); |
665 | 650 |
666 // Returns whether the given URL is allowed to commit in the current process. | 651 // Returns whether the given URL is allowed to commit in the current process. |
667 // This is a more conservative check than RenderProcessHost::FilterURL, since | 652 // This is a more conservative check than RenderProcessHost::FilterURL, since |
668 // it will be used to kill processes that commit unauthorized URLs. | 653 // it will be used to kill processes that commit unauthorized URLs. |
669 bool CanCommitURL(const GURL& url); | 654 bool CanCommitURL(const GURL& url); |
670 | 655 |
671 // Returns whether the given origin is allowed to commit in the current | 656 // Returns whether the given origin is allowed to commit in the current |
672 // RenderFrameHost. The |url| is used to ensure it matches the origin in cases | 657 // RenderFrameHost. The |url| is used to ensure it matches the origin in cases |
673 // where it is applicable. This is a more conservative check than | 658 // where it is applicable. This is a more conservative check than |
674 // RenderProcessHost::FilterURL, since it will be used to kill processes that | 659 // RenderProcessHost::FilterURL, since it will be used to kill processes that |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 // RenderFrameHosts that need management of the rendering and input events | 775 // RenderFrameHosts that need management of the rendering and input events |
791 // for their frame subtrees require RenderWidgetHosts. This typically | 776 // for their frame subtrees require RenderWidgetHosts. This typically |
792 // means frames that are rendered in different processes from their parent | 777 // means frames that are rendered in different processes from their parent |
793 // frames. | 778 // frames. |
794 // TODO(kenrb): Later this will also be used on the top-level frame, when | 779 // TODO(kenrb): Later this will also be used on the top-level frame, when |
795 // RenderFrameHost owns its RenderViewHost. | 780 // RenderFrameHost owns its RenderViewHost. |
796 RenderWidgetHostImpl* render_widget_host_; | 781 RenderWidgetHostImpl* render_widget_host_; |
797 | 782 |
798 int routing_id_; | 783 int routing_id_; |
799 | 784 |
800 // The current state of this RenderFrameHost. | 785 // Boolean indicating whether this RenderFrameHost is being actively used or |
801 RenderFrameHostImplState rfh_state_; | 786 // is waiting for FrameHostMsg_SwapOut_ACK and pending deletion. |
Charlie Reis
2016/04/04 17:16:36
nit: and thus pending deletion.
nasko
2016/04/08 17:42:07
Done.
| |
787 bool is_waiting_for_swapout_ack_; | |
802 | 788 |
803 // Tracks whether the RenderFrame for this RenderFrameHost has been created in | 789 // Tracks whether the RenderFrame for this RenderFrameHost has been created in |
804 // the renderer process. Currently only used for subframes. | 790 // the renderer process. Currently only used for subframes. |
805 // TODO(creis): Use this for main frames as well when RVH goes away. | 791 // TODO(creis): Use this for main frames as well when RVH goes away. |
806 bool render_frame_created_; | 792 bool render_frame_created_; |
807 | 793 |
808 // Whether we should buffer outgoing Navigate messages rather than sending | 794 // Whether we should buffer outgoing Navigate messages rather than sending |
809 // them. This will be true when a RenderFrameHost is created for a cross-site | 795 // them. This will be true when a RenderFrameHost is created for a cross-site |
810 // request, until we hear back from the onbeforeunload handler of the old | 796 // request, until we hear back from the onbeforeunload handler of the old |
811 // RenderFrameHost. | 797 // RenderFrameHost. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 | 928 |
943 // NOTE: This must be the last member. | 929 // NOTE: This must be the last member. |
944 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 930 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
945 | 931 |
946 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 932 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
947 }; | 933 }; |
948 | 934 |
949 } // namespace content | 935 } // namespace content |
950 | 936 |
951 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 937 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |