Chromium Code Reviews| 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 has been |
| 363 RenderFrameHostImplState rfh_state() const { return rfh_state_; } | 348 // created. It returns false, once SwapOut is called and the object is pending |
| 349 // deletion. | |
|
Charlie Reis
2016/04/08 20:25:37
Just some wordsmithing:
This method returns true
nasko
2016/04/08 21:25:32
Done.
| |
| 350 bool is_active() { return !is_waiting_for_swapout_ack_; } | |
| 364 | 351 |
| 365 // Sends the given navigation message. Use this rather than sending it | 352 // Sends the given navigation message. Use this rather than sending it |
| 366 // yourself since this does the internal bookkeeping described below. This | 353 // yourself since this does the internal bookkeeping described below. This |
| 367 // function takes ownership of the provided message pointer. | 354 // function takes ownership of the provided message pointer. |
| 368 // | 355 // |
| 369 // If a cross-site request is in progress, we may be suspended while waiting | 356 // 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 | 357 // for the onbeforeunload handler, so this function might buffer the message |
| 371 // rather than sending it. | 358 // rather than sending it. |
| 372 void Navigate(const CommonNavigationParams& common_params, | 359 void Navigate(const CommonNavigationParams& common_params, |
| 373 const StartNavigationParams& start_params, | 360 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); | 664 const std::set<std::string>& digests_of_uris_of_serialized_resources); |
| 678 | 665 |
| 679 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 666 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 680 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); | 667 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); |
| 681 void OnHidePopup(); | 668 void OnHidePopup(); |
| 682 #endif | 669 #endif |
| 683 | 670 |
| 684 // Registers Mojo services that this frame host makes available. | 671 // Registers Mojo services that this frame host makes available. |
| 685 void RegisterMojoServices(); | 672 void RegisterMojoServices(); |
| 686 | 673 |
| 687 // Updates the state of this RenderFrameHost and clears any waiting state | 674 // Resets any waiting state of this RenderFrameHost that is no longer |
| 688 // that is no longer relevant. | 675 // relevant. |
| 689 void SetState(RenderFrameHostImplState rfh_state); | 676 void ResetWaitingState(); |
| 690 | 677 |
| 691 // Returns whether the given URL is allowed to commit in the current process. | 678 // Returns whether the given URL is allowed to commit in the current process. |
| 692 // This is a more conservative check than RenderProcessHost::FilterURL, since | 679 // This is a more conservative check than RenderProcessHost::FilterURL, since |
| 693 // it will be used to kill processes that commit unauthorized URLs. | 680 // it will be used to kill processes that commit unauthorized URLs. |
| 694 bool CanCommitURL(const GURL& url); | 681 bool CanCommitURL(const GURL& url); |
| 695 | 682 |
| 696 // Returns whether the given origin is allowed to commit in the current | 683 // 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 | 684 // 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 | 685 // where it is applicable. This is a more conservative check than |
| 699 // RenderProcessHost::FilterURL, since it will be used to kill processes that | 686 // 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 | 810 // RenderFrameHosts that need management of the rendering and input events |
| 824 // for their frame subtrees require RenderWidgetHosts. This typically | 811 // for their frame subtrees require RenderWidgetHosts. This typically |
| 825 // means frames that are rendered in different processes from their parent | 812 // means frames that are rendered in different processes from their parent |
| 826 // frames. | 813 // frames. |
| 827 // TODO(kenrb): Later this will also be used on the top-level frame, when | 814 // TODO(kenrb): Later this will also be used on the top-level frame, when |
| 828 // RenderFrameHost owns its RenderViewHost. | 815 // RenderFrameHost owns its RenderViewHost. |
| 829 RenderWidgetHostImpl* render_widget_host_; | 816 RenderWidgetHostImpl* render_widget_host_; |
| 830 | 817 |
| 831 int routing_id_; | 818 int routing_id_; |
| 832 | 819 |
| 833 // The current state of this RenderFrameHost. | 820 // Boolean indicating whether this RenderFrameHost is being actively used or |
| 834 RenderFrameHostImplState rfh_state_; | 821 // is waiting for FrameHostMsg_SwapOut_ACK and thus pending deletion. |
| 822 bool is_waiting_for_swapout_ack_; | |
| 835 | 823 |
| 836 // Tracks whether the RenderFrame for this RenderFrameHost has been created in | 824 // Tracks whether the RenderFrame for this RenderFrameHost has been created in |
| 837 // the renderer process. Currently only used for subframes. | 825 // the renderer process. Currently only used for subframes. |
| 838 // TODO(creis): Use this for main frames as well when RVH goes away. | 826 // TODO(creis): Use this for main frames as well when RVH goes away. |
| 839 bool render_frame_created_; | 827 bool render_frame_created_; |
| 840 | 828 |
| 841 // Whether we should buffer outgoing Navigate messages rather than sending | 829 // 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 | 830 // 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 | 831 // request, until we hear back from the onbeforeunload handler of the old |
| 844 // RenderFrameHost. | 832 // RenderFrameHost. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 | 964 |
| 977 // NOTE: This must be the last member. | 965 // NOTE: This must be the last member. |
| 978 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 966 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
| 979 | 967 |
| 980 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 968 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| 981 }; | 969 }; |
| 982 | 970 |
| 983 } // namespace content | 971 } // namespace content |
| 984 | 972 |
| 985 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 973 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| OLD | NEW |