| 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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 : public RenderFrameHost, | 68 : public RenderFrameHost, |
| 69 public BrowserAccessibilityDelegate { | 69 public BrowserAccessibilityDelegate { |
| 70 public: | 70 public: |
| 71 // Keeps track of the state of the RenderFrameHostImpl, particularly with | 71 // Keeps track of the state of the RenderFrameHostImpl, particularly with |
| 72 // respect to swap out. | 72 // respect to swap out. |
| 73 enum RenderFrameHostImplState { | 73 enum RenderFrameHostImplState { |
| 74 // The standard state for a RFH handling the communication with an active | 74 // The standard state for a RFH handling the communication with an active |
| 75 // RenderFrame. | 75 // RenderFrame. |
| 76 STATE_DEFAULT = 0, | 76 STATE_DEFAULT = 0, |
| 77 // The RFH has not received the SwapOutACK yet, but the new page has | 77 // The RFH has not received the SwapOutACK yet, but the new page has |
| 78 // committed in a different RFH. The number of active frames of the RFH | 78 // committed in a different RFH. Upon reception of the SwapOutACK, the RFH |
| 79 // SiteInstanceImpl is not zero. Upon reception of the SwapOutACK, the RFH | 79 // will either enter STATE_SWAPPED_OUT (if it is a main frame and there are |
| 80 // will be swapped out. | 80 // other active frames in its SiteInstance) or it will be deleted. |
| 81 STATE_PENDING_SWAP_OUT, | 81 STATE_PENDING_SWAP_OUT, |
| 82 // The RFH has not received the SwapOutACK yet, but the new page has | |
| 83 // committed in a different RFH. The number of active frames of the RFH | |
| 84 // SiteInstanceImpl is zero. Upon reception of the SwapOutACK, the RFH will | |
| 85 // be shutdown. | |
| 86 STATE_PENDING_SHUTDOWN, | |
| 87 // The RFH is swapped out and stored inside a RenderFrameProxyHost, being | 82 // The RFH is swapped out and stored inside a RenderFrameProxyHost, being |
| 88 // used as a placeholder to allow cross-process communication. | 83 // used as a placeholder to allow cross-process communication. Only main |
| 84 // frames can enter this state. |
| 89 STATE_SWAPPED_OUT, | 85 STATE_SWAPPED_OUT, |
| 90 }; | 86 }; |
| 91 // Helper function to determine whether the RFH state should contribute to the | 87 // Helper function to determine whether the RFH state should contribute to the |
| 92 // number of active frames of a SiteInstance or not. | 88 // number of active frames of a SiteInstance or not. |
| 93 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state); | 89 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state); |
| 94 | 90 |
| 95 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 91 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
| 96 | 92 |
| 97 virtual ~RenderFrameHostImpl(); | 93 virtual ~RenderFrameHostImpl(); |
| 98 | 94 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 ui::PageTransition page_transition, | 203 ui::PageTransition page_transition, |
| 208 bool should_replace_current_entry); | 204 bool should_replace_current_entry); |
| 209 | 205 |
| 210 // Called on the current RenderFrameHost when the network response is first | 206 // Called on the current RenderFrameHost when the network response is first |
| 211 // receieved. | 207 // receieved. |
| 212 void OnDeferredAfterResponseStarted( | 208 void OnDeferredAfterResponseStarted( |
| 213 const GlobalRequestID& global_request_id, | 209 const GlobalRequestID& global_request_id, |
| 214 const TransitionLayerData& transition_data); | 210 const TransitionLayerData& transition_data); |
| 215 | 211 |
| 216 // Tells the renderer that this RenderFrame is being swapped out for one in a | 212 // Tells the renderer that this RenderFrame is being swapped out for one in a |
| 217 // different renderer process. It should run its unload handler, move to | 213 // different renderer process. It should run its unload handler and move to |
| 218 // a blank document and create a RenderFrameProxy to replace the RenderFrame. | 214 // a blank document. If |proxy| is not null, it should also create a |
| 219 // The renderer should preserve the Proxy object until it exits, in case we | 215 // RenderFrameProxy to replace the RenderFrame. The renderer should preserve |
| 220 // come back. The renderer can exit if it has no other active RenderFrames, | 216 // the RenderFrameProxy object until it exits, in case we come back. The |
| 221 // but not until WasSwappedOut is called (when it is no longer visible). | 217 // renderer can exit if it has no other active RenderFrames, but not until |
| 218 // WasSwappedOut is called. |
| 222 void SwapOut(RenderFrameProxyHost* proxy); | 219 void SwapOut(RenderFrameProxyHost* proxy); |
| 223 | 220 |
| 224 bool is_waiting_for_beforeunload_ack() const { | 221 bool is_waiting_for_beforeunload_ack() const { |
| 225 return is_waiting_for_beforeunload_ack_; | 222 return is_waiting_for_beforeunload_ack_; |
| 226 } | 223 } |
| 227 | 224 |
| 228 // Whether the RFH is waiting for an unload ACK from the renderer. | 225 // Whether the RFH is waiting for an unload ACK from the renderer. |
| 229 bool IsWaitingForUnloadACK() const; | 226 bool IsWaitingForUnloadACK() const; |
| 230 | 227 |
| 231 // Called when either the SwapOut request has been acknowledged or has timed | 228 // Called when either the SwapOut request has been acknowledged or has timed |
| 232 // out. | 229 // out. |
| 233 void OnSwappedOut(); | 230 void OnSwappedOut(); |
| 234 | 231 |
| 235 // Whether this RenderFrameHost has been swapped out, such that the frame is | 232 // Whether this RenderFrameHost has been swapped out, such that the frame is |
| 236 // now rendered by a RenderFrameHost in a different process. | 233 // now rendered by a RenderFrameHost in a different process. |
| 237 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; } | 234 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; } |
| 238 | 235 |
| 239 // The current state of this RFH. | 236 // The current state of this RFH. |
| 240 RenderFrameHostImplState rfh_state() const { return rfh_state_; } | 237 RenderFrameHostImplState rfh_state() const { return rfh_state_; } |
| 241 | 238 |
| 242 // Set |this| as pending shutdown. |on_swap_out| will be called | |
| 243 // when the SwapOutACK is received, or when the unload timer times out. | |
| 244 void SetPendingShutdown(const base::Closure& on_swap_out); | |
| 245 | |
| 246 // Sends the given navigation message. Use this rather than sending it | 239 // Sends the given navigation message. Use this rather than sending it |
| 247 // yourself since this does the internal bookkeeping described below. This | 240 // yourself since this does the internal bookkeeping described below. This |
| 248 // function takes ownership of the provided message pointer. | 241 // function takes ownership of the provided message pointer. |
| 249 // | 242 // |
| 250 // If a cross-site request is in progress, we may be suspended while waiting | 243 // If a cross-site request is in progress, we may be suspended while waiting |
| 251 // for the onbeforeunload handler, so this function might buffer the message | 244 // for the onbeforeunload handler, so this function might buffer the message |
| 252 // rather than sending it. | 245 // rather than sending it. |
| 253 void Navigate(const FrameMsg_Navigate_Params& params); | 246 void Navigate(const FrameMsg_Navigate_Params& params); |
| 254 | 247 |
| 255 // Load the specified URL; this is a shortcut for Navigate(). | 248 // Load the specified URL; this is a shortcut for Navigate(). |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 // IsWaitingForUnloadACK is true. This tells us if the unload request | 538 // IsWaitingForUnloadACK is true. This tells us if the unload request |
| 546 // is for closing the entire tab ( = false), or only this RenderFrameHost in | 539 // is for closing the entire tab ( = false), or only this RenderFrameHost in |
| 547 // the case of a cross-site transition ( = true). | 540 // the case of a cross-site transition ( = true). |
| 548 bool unload_ack_is_for_cross_site_transition_; | 541 bool unload_ack_is_for_cross_site_transition_; |
| 549 | 542 |
| 550 // Used to swap out or shut down this RFH when the unload event is taking too | 543 // Used to swap out or shut down this RFH when the unload event is taking too |
| 551 // long to execute, depending on the number of active frames in the | 544 // long to execute, depending on the number of active frames in the |
| 552 // SiteInstance. | 545 // SiteInstance. |
| 553 scoped_ptr<TimeoutMonitor> swapout_event_monitor_timeout_; | 546 scoped_ptr<TimeoutMonitor> swapout_event_monitor_timeout_; |
| 554 | 547 |
| 555 // Called after receiving the SwapOutACK when the RFH is in the pending | |
| 556 // shutdown state. Also called if the unload timer times out. | |
| 557 base::Closure pending_shutdown_on_swap_out_; | |
| 558 | |
| 559 ServiceRegistryImpl service_registry_; | 548 ServiceRegistryImpl service_registry_; |
| 560 | 549 |
| 561 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; | 550 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
| 562 | 551 |
| 563 // Callback when an event is received, for testing. | 552 // Callback when an event is received, for testing. |
| 564 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; | 553 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; |
| 565 // The most recently received accessibility tree - for testing only. | 554 // The most recently received accessibility tree - for testing only. |
| 566 scoped_ptr<ui::AXTree> ax_tree_for_testing_; | 555 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
| 567 | 556 |
| 568 // NOTE: This must be the last member. | 557 // NOTE: This must be the last member. |
| 569 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 558 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
| 570 | 559 |
| 571 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 560 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| 572 }; | 561 }; |
| 573 | 562 |
| 574 } // namespace content | 563 } // namespace content |
| 575 | 564 |
| 576 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 565 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| OLD | NEW |