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_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 class CrossProcessFrameConnector; | 23 class CrossProcessFrameConnector; |
| 24 class CrossSiteTransferringRequest; | 24 class CrossSiteTransferringRequest; |
| 25 class InterstitialPageImpl; | 25 class InterstitialPageImpl; |
| 26 class FrameTreeNode; | 26 class FrameTreeNode; |
| 27 class NavigationControllerImpl; | 27 class NavigationControllerImpl; |
| 28 class NavigationEntry; | 28 class NavigationEntry; |
| 29 class NavigationEntryImpl; | 29 class NavigationEntryImpl; |
| 30 class RenderFrameHostDelegate; | 30 class RenderFrameHostDelegate; |
| 31 class RenderFrameHostImpl; | 31 class RenderFrameHostImpl; |
| 32 class RenderFrameHostManagerTest; | 32 class RenderFrameHostManagerTest; |
| 33 class RenderFrameProxyHost; | |
| 33 class RenderViewHost; | 34 class RenderViewHost; |
| 34 class RenderViewHostImpl; | 35 class RenderViewHostImpl; |
| 35 class RenderWidgetHostDelegate; | 36 class RenderWidgetHostDelegate; |
| 36 class RenderWidgetHostView; | 37 class RenderWidgetHostView; |
| 37 class TestWebContents; | 38 class TestWebContents; |
| 38 class WebUIImpl; | 39 class WebUIImpl; |
| 39 | 40 |
| 40 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state | 41 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state |
| 41 // machine to make cross-process navigations in a frame possible. | 42 // machine to make cross-process navigations in a frame possible. |
| 42 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { | 43 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 | 262 |
| 262 // Called when a RenderViewHost is about to be deleted. | 263 // Called when a RenderViewHost is about to be deleted. |
| 263 void RenderViewDeleted(RenderViewHost* rvh); | 264 void RenderViewDeleted(RenderViewHost* rvh); |
| 264 | 265 |
| 265 // Returns whether the given RenderFrameHost (or its associated | 266 // Returns whether the given RenderFrameHost (or its associated |
| 266 // RenderViewHost) is on the list of swapped out RenderFrameHosts. | 267 // RenderViewHost) is on the list of swapped out RenderFrameHosts. |
| 267 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; | 268 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; |
| 268 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; | 269 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; |
| 269 | 270 |
| 270 // Returns the swapped out RenderViewHost or RenderFrameHost for the given | 271 // Returns the swapped out RenderViewHost or RenderFrameHost for the given |
| 271 // SiteInstance, if any. | 272 // SiteInstance, if any. |
|
Charlie Reis
2014/03/31 23:22:35
Maybe add a TODO comment saying that GetSwappedOut
nasko
2014/04/09 17:52:01
Done.
| |
| 272 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; | 273 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; |
| 273 RenderFrameHostImpl* GetSwappedOutRenderFrameHost( | 274 RenderFrameProxyHost* GetRenderFrameProxyHost( |
| 274 SiteInstance* instance) const; | 275 SiteInstance* instance) const; |
| 275 | 276 |
| 276 // Runs the unload handler in the current page, when we know that a pending | 277 // Runs the unload handler in the current page, when we know that a pending |
| 277 // cross-process navigation is going to commit. We may initiate a transfer | 278 // cross-process navigation is going to commit. We may initiate a transfer |
| 278 // to a new process after this completes or times out. | 279 // to a new process after this completes or times out. |
| 279 void SwapOutOldPage(); | 280 void SwapOutOldPage(); |
| 280 | 281 |
| 281 // Deletes a RenderFrameHost that was pending shutdown. | 282 // Deletes a RenderFrameHost that was pending shutdown. |
| 282 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, | 283 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, |
| 283 RenderFrameHostImpl* rfh); | 284 RenderFrameHostImpl* rfh); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 // This is the transition type for the original navigation. | 325 // This is the transition type for the original navigation. |
| 325 PageTransition page_transition; | 326 PageTransition page_transition; |
| 326 | 327 |
| 327 // This is the frame routing ID to use in RequestTransferURL. | 328 // This is the frame routing ID to use in RequestTransferURL. |
| 328 int render_frame_id; | 329 int render_frame_id; |
| 329 | 330 |
| 330 // This is whether the navigation should replace the current history entry. | 331 // This is whether the navigation should replace the current history entry. |
| 331 bool should_replace_current_entry; | 332 bool should_replace_current_entry; |
| 332 }; | 333 }; |
| 333 | 334 |
| 334 // Used with FrameTree::ForEach to erase inactive RenderFrameHosts from a | 335 // Used with FrameTree::ForEach to erase inactive RenderFrameHosts from a |
|
Charlie Reis
2014/03/31 23:22:35
I imagine there's a bunch of comments we'll want t
nasko
2014/04/09 17:52:01
Done.
| |
| 335 // FrameTreeNode's RenderFrameHostManager. | 336 // FrameTreeNode's RenderFrameHostManager. |
| 336 static bool ClearSwappedOutRFHsInSiteInstance(int32 site_instance_id, | 337 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
| 337 FrameTreeNode* node); | 338 FrameTreeNode* node); |
| 338 | 339 |
| 339 // Returns whether this tab should transition to a new renderer for | 340 // Returns whether this tab should transition to a new renderer for |
| 340 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 341 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
| 341 // switch. Can be overridden in unit tests. | 342 // switch. Can be overridden in unit tests. |
| 342 bool ShouldTransitionCrossSite(); | 343 bool ShouldTransitionCrossSite(); |
| 343 | 344 |
| 344 // Returns true if for the navigation from |current_entry| to |new_entry|, | 345 // Returns true if for the navigation from |current_entry| to |new_entry|, |
| 345 // a new SiteInstance and BrowsingInstance should be created (even if we are | 346 // a new SiteInstance and BrowsingInstance should be created (even if we are |
| 346 // in a process model that doesn't usually swap). This forces a process swap | 347 // in a process model that doesn't usually swap). This forces a process swap |
| 347 // and severs script connections with existing tabs. Cases where this can | 348 // and severs script connections with existing tabs. Cases where this can |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 360 // Returns an appropriate SiteInstance object for the given NavigationEntry, | 361 // Returns an appropriate SiteInstance object for the given NavigationEntry, |
| 361 // possibly reusing the current SiteInstance. If --process-per-tab is used, | 362 // possibly reusing the current SiteInstance. If --process-per-tab is used, |
| 362 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns | 363 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns |
| 363 // true. | 364 // true. |
| 364 SiteInstance* GetSiteInstanceForEntry( | 365 SiteInstance* GetSiteInstanceForEntry( |
| 365 const NavigationEntryImpl& entry, | 366 const NavigationEntryImpl& entry, |
| 366 SiteInstance* current_instance, | 367 SiteInstance* current_instance, |
| 367 bool force_browsing_instance_swap); | 368 bool force_browsing_instance_swap); |
| 368 | 369 |
| 369 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 370 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| 370 RenderFrameHostImpl* CreateRenderFrameHost(SiteInstance* instance, | 371 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| 371 int view_routing_id, | 372 int view_routing_id, |
| 372 int frame_routing_id, | 373 int frame_routing_id, |
| 373 bool swapped_out, | 374 bool swapped_out, |
| 374 bool hidden); | 375 bool hidden); |
| 375 | 376 |
| 376 // Sets up the necessary state for a new RenderViewHost with the given opener, | 377 // Sets up the necessary state for a new RenderViewHost with the given opener, |
| 377 // if necessary. Returns early if the RenderViewHost has already been | 378 // if necessary. Returns early if the RenderViewHost has already been |
| 378 // initialized for another RenderFrameHost. | 379 // initialized for another RenderFrameHost. |
| 379 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 380 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
| 380 // be for the RenderFrame, since frames can have openers. | 381 // be for the RenderFrame, since frames can have openers. |
| 381 bool InitRenderView(RenderViewHost* render_view_host, int opener_route_id); | 382 bool InitRenderView(RenderViewHost* render_view_host, int opener_route_id); |
| 382 | 383 |
| 383 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 384 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
| 384 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 385 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 // Tracks information about any current pending cross-process navigation. | 441 // Tracks information about any current pending cross-process navigation. |
| 441 scoped_ptr<PendingNavigationParams> pending_nav_params_; | 442 scoped_ptr<PendingNavigationParams> pending_nav_params_; |
| 442 | 443 |
| 443 // If either of these is non-NULL, the pending navigation is to a chrome: | 444 // If either of these is non-NULL, the pending navigation is to a chrome: |
| 444 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is | 445 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is |
| 445 // used for when they reference the same object. If either is non-NULL, the | 446 // used for when they reference the same object. If either is non-NULL, the |
| 446 // other should be NULL. | 447 // other should be NULL. |
| 447 scoped_ptr<WebUIImpl> pending_web_ui_; | 448 scoped_ptr<WebUIImpl> pending_web_ui_; |
| 448 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; | 449 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
| 449 | 450 |
| 450 // A map of site instance ID to swapped out RenderFrameHosts. This may | 451 // A map of site instance ID to swapped out RenderFrameHosts. This may |
|
Charlie Reis
2014/03/31 23:22:35
to RenderFrameProxyHosts?
nasko
2014/04/09 17:52:01
Done.
| |
| 451 // include pending_render_frame_host_ for navigations to existing entries. | 452 // include pending_render_frame_host_ for navigations to existing entries. |
|
Charlie Reis
2014/03/31 23:22:35
Is this part still accurate?
nasko
2014/04/09 17:52:01
Done.
| |
| 452 typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap; | 453 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameHostMap; |
| 453 RenderFrameHostMap swapped_out_hosts_; | 454 RenderFrameHostMap proxy_hosts_; |
| 454 | 455 |
| 455 // A map of RenderFrameHosts pending shutdown. | 456 // A map of RenderFrameHosts pending shutdown. |
| 456 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > | 457 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > |
| 457 RFHPendingDeleteMap; | 458 RFHPendingDeleteMap; |
| 458 RFHPendingDeleteMap pending_delete_hosts_; | 459 RFHPendingDeleteMap pending_delete_hosts_; |
| 459 | 460 |
| 460 // The intersitial page currently shown if any, not own by this class | 461 // The intersitial page currently shown if any, not own by this class |
| 461 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 462 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 462 InterstitialPageImpl* interstitial_page_; | 463 InterstitialPageImpl* interstitial_page_; |
| 463 | 464 |
| 464 NotificationRegistrar registrar_; | 465 NotificationRegistrar registrar_; |
| 465 | 466 |
| 466 // When |render_frame_host_| is in a different process from its parent in | 467 // When |render_frame_host_| is in a different process from its parent in |
| 467 // the frame tree, this class connects its associated RenderWidgetHostView | 468 // the frame tree, this class connects its associated RenderWidgetHostView |
| 468 // to the proxy RenderFrameHost for the parent's renderer process. NULL | 469 // to the proxy RenderFrameHost for the parent's renderer process. NULL |
| 469 // when |render_frame_host_| is the frame tree root or is in the same | 470 // when |render_frame_host_| is the frame tree root or is in the same |
| 470 // process as its parent. | 471 // process as its parent. |
| 471 CrossProcessFrameConnector* cross_process_frame_connector_; | 472 CrossProcessFrameConnector* cross_process_frame_connector_; |
| 472 | 473 |
| 473 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 474 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 474 | 475 |
| 475 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 476 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 476 }; | 477 }; |
| 477 | 478 |
| 478 } // namespace content | 479 } // namespace content |
| 479 | 480 |
| 480 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 481 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |