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 <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/browser/renderer_host/render_view_host_delegate.h" | 14 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/global_request_id.h" | 17 #include "content/public/browser/global_request_id.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
| 21 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
| 22 | 22 |
| 23 struct FrameHostMsg_BeginNavigation_Params; | |
|
nasko
2014/11/10 17:35:31
Why are these structs outside of the content names
clamy
2014/11/12 13:01:13
They are defined that way in frame_messages.h (and
carlosk
2014/11/13 14:40:26
Yes, that.
| |
| 23 struct FrameMsg_Navigate_Params; | 24 struct FrameMsg_Navigate_Params; |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class BrowserContext; | 27 class BrowserContext; |
| 27 class CrossProcessFrameConnector; | 28 class CrossProcessFrameConnector; |
| 28 class CrossSiteTransferringRequest; | 29 class CrossSiteTransferringRequest; |
| 30 class FrameTreeNode; | |
| 29 class InterstitialPageImpl; | 31 class InterstitialPageImpl; |
| 30 class FrameTreeNode; | |
| 31 class NavigationControllerImpl; | 32 class NavigationControllerImpl; |
| 32 class NavigationEntry; | 33 class NavigationEntry; |
| 33 class NavigationEntryImpl; | 34 class NavigationEntryImpl; |
| 34 class RenderFrameHost; | 35 class RenderFrameHost; |
| 35 class RenderFrameHostDelegate; | 36 class RenderFrameHostDelegate; |
| 36 class RenderFrameHost; | |
| 37 class RenderFrameHostImpl; | 37 class RenderFrameHostImpl; |
| 38 class RenderFrameHostManagerTest; | 38 class RenderFrameHostManagerTest; |
| 39 class RenderFrameProxyHost; | 39 class RenderFrameProxyHost; |
| 40 class RenderViewHost; | 40 class RenderViewHost; |
| 41 class RenderViewHostImpl; | 41 class RenderViewHostImpl; |
| 42 class RenderWidgetHostDelegate; | 42 class RenderWidgetHostDelegate; |
| 43 class RenderWidgetHostView; | 43 class RenderWidgetHostView; |
| 44 class TestWebContents; | 44 class TestWebContents; |
| 45 class WebUIImpl; | 45 class WebUIImpl; |
| 46 struct CommonNavigationParams; | |
| 46 | 47 |
| 47 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a | 48 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a |
| 48 // current_frame_host() which is the content currently visible to the user. When | 49 // current_frame_host() which is the content currently visible to the user. When |
| 49 // a frame is told to navigate to a different web site (as determined by | 50 // a frame is told to navigate to a different web site (as determined by |
| 50 // SiteInstance), it will replace its current RenderFrameHost with a new | 51 // SiteInstance), it will replace its current RenderFrameHost with a new |
| 51 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. | 52 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. |
| 52 // | 53 // |
| 53 // Cross-process navigation works like this: | 54 // Cross-process navigation works like this: |
| 54 // | 55 // |
| 55 // - RFHM::Navigate determines whether the destination is cross-site, and if so, | 56 // - RFHM::Navigate determines whether the destination is cross-site, and if so, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 288 |
| 288 // Resume navigation paused after receiving response headers. | 289 // Resume navigation paused after receiving response headers. |
| 289 void ResumeResponseDeferredAtStart(); | 290 void ResumeResponseDeferredAtStart(); |
| 290 | 291 |
| 291 // Clear navigation transition data. | 292 // Clear navigation transition data. |
| 292 void ClearNavigationTransitionData(); | 293 void ClearNavigationTransitionData(); |
| 293 | 294 |
| 294 // Called when a renderer's frame navigates. | 295 // Called when a renderer's frame navigates. |
| 295 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); | 296 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); |
| 296 | 297 |
| 298 // PlzNavigate | |
| 299 // Cleans up ongoing navigation data. | |
| 300 void CancelNavigation(); | |
| 301 | |
| 297 // Called when a renderer sets its opener to null. | 302 // Called when a renderer sets its opener to null. |
| 298 void DidDisownOpener(RenderFrameHost* render_frame_host); | 303 void DidDisownOpener(RenderFrameHost* render_frame_host); |
| 299 | 304 |
| 300 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| | 305 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
| 301 // is true, it will be initially placed on the swapped out hosts list. | 306 // is true, it will be initially placed on the swapped out hosts list. |
| 302 // Returns the routing id of the *view* associated with the frame. | 307 // Returns the routing id of the *view* associated with the frame. |
| 303 int CreateRenderFrame(SiteInstance* instance, | 308 int CreateRenderFrame(SiteInstance* instance, |
| 304 int opener_route_id, | 309 int opener_route_id, |
| 305 bool swapped_out, | 310 bool swapped_out, |
| 306 bool for_main_frame_navigation, | 311 bool for_main_frame_navigation, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 360 |
| 356 // Deletes any proxy hosts associated with this node. Used during destruction | 361 // Deletes any proxy hosts associated with this node. Used during destruction |
| 357 // of WebContentsImpl. | 362 // of WebContentsImpl. |
| 358 void ResetProxyHosts(); | 363 void ResetProxyHosts(); |
| 359 | 364 |
| 360 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 365 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
| 361 // that has the given SiteInstance and is associated with this | 366 // that has the given SiteInstance and is associated with this |
| 362 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 367 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 363 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 368 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 364 | 369 |
| 365 // PlzNavigate: Called when a navigation is ready to commit, to select the | 370 // PlzNavigate |
| 366 // renderer that will commit it. | 371 // Notifies the RFHM that a navigation is about to begin so that it can |
| 372 // speculatively spawn a new renderer process. | |
|
clamy
2014/11/12 13:01:13
nit: add "if needed" at the end of the comment.
carlosk
2014/11/13 14:40:26
Done.
| |
| 373 void BeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, | |
| 374 const CommonNavigationParams& common_params); | |
| 375 | |
| 376 // PlzNavigate | |
| 377 // Called when a navigation is ready to commit, to select the renderer that | |
| 378 // will commit it. | |
| 367 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 379 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
| 368 ui::PageTransition transition); | 380 ui::PageTransition transition); |
| 369 | 381 |
| 370 private: | 382 private: |
| 371 friend class RenderFrameHostManagerTest; | 383 friend class RenderFrameHostManagerTest; |
| 372 friend class TestWebContents; | 384 friend class TestWebContents; |
| 373 | 385 |
| 374 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 386 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
| 375 CreateCrossProcessSubframeProxies); | 387 CreateCrossProcessSubframeProxies); |
| 376 | 388 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 bool ShouldReuseWebUI( | 421 bool ShouldReuseWebUI( |
| 410 const NavigationEntry* current_entry, | 422 const NavigationEntry* current_entry, |
| 411 const GURL& new_url) const; | 423 const GURL& new_url) const; |
| 412 | 424 |
| 413 // Returns the SiteInstance to use for the navigation. | 425 // Returns the SiteInstance to use for the navigation. |
| 414 SiteInstance* GetSiteInstanceForNavigation( | 426 SiteInstance* GetSiteInstanceForNavigation( |
| 415 const GURL& dest_url, | 427 const GURL& dest_url, |
| 416 SiteInstance* dest_instance, | 428 SiteInstance* dest_instance, |
| 417 ui::PageTransition dest_transition, | 429 ui::PageTransition dest_transition, |
| 418 bool dest_is_restore, | 430 bool dest_is_restore, |
| 419 bool dest_is_view_source_mode); | 431 bool dest_is_view_source_mode, |
| 432 bool create_unbounded_site_instance); | |
| 420 | 433 |
| 421 // Returns an appropriate SiteInstance object for the given |dest_url|, | 434 // Returns an appropriate SiteInstance object for the given |dest_url|, |
| 422 // possibly reusing the current SiteInstance. If --process-per-tab is used, | 435 // possibly reusing the current SiteInstance. If --process-per-tab is used, |
| 423 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns | 436 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns |
| 424 // true. |dest_instance| will be used if it is not null. | 437 // true. |dest_instance| will be used if it is not null. |
| 425 // This is a helper function for GetSiteInstanceForNavigation. | 438 // This is a helper function for GetSiteInstanceForNavigation. |
| 426 SiteInstance* GetSiteInstanceForURL( | 439 SiteInstance* GetSiteInstanceForURL(const GURL& dest_url, |
| 427 const GURL& dest_url, | 440 SiteInstance* dest_instance, |
| 428 SiteInstance* dest_instance, | 441 ui::PageTransition dest_transition, |
| 429 ui::PageTransition dest_transition, | 442 bool dest_is_restore, |
| 430 bool dest_is_restore, | 443 bool dest_is_view_source_mode, |
| 431 bool dest_is_view_source_mode, | 444 SiteInstance* current_instance, |
| 432 SiteInstance* current_instance, | 445 bool force_browsing_instance_swap, |
| 433 bool force_browsing_instance_swap); | 446 bool create_unbounded_site_instance); |
| 447 | |
| 448 SiteInstance* CreateSiteInstanceForURL(BrowserContext* browser_context, | |
| 449 const GURL& creation_url, | |
| 450 bool create_unbounded_site_instance, | |
| 451 SiteInstanceImpl* current_instance); | |
| 452 | |
| 453 SiteInstance* GetRelatedSiteInstanceForURL( | |
| 454 SiteInstanceImpl* current_instance, | |
| 455 const GURL& creation_url, | |
| 456 bool create_unbounded_site_instance); | |
| 434 | 457 |
| 435 // Determines the appropriate url to use as the current url for SiteInstance | 458 // Determines the appropriate url to use as the current url for SiteInstance |
| 436 // selection. | 459 // selection. |
| 437 const GURL& GetCurrentURLForSiteInstance( | 460 const GURL& GetCurrentURLForSiteInstance( |
| 438 SiteInstance* current_instance, | 461 SiteInstance* current_instance, |
| 439 NavigationEntry* current_entry); | 462 NavigationEntry* current_entry); |
| 440 | 463 |
| 441 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting | 464 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting |
| 442 // the opener route if needed and stores it in pending_render_frame_host_. | 465 // the opener route if needed and stores it in pending_render_frame_host_. |
| 443 void CreateRenderFrameHostForNewSiteInstance( | 466 void CreateRenderFrameHostForNewSiteInstance( |
| 444 SiteInstance* old_instance, | 467 SiteInstance* old_instance, |
| 445 SiteInstance* new_instance, | 468 SiteInstance* new_instance, |
| 446 bool is_main_frame); | 469 bool is_main_frame); |
| 447 | 470 |
| 448 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 471 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| 449 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 472 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| 450 int view_routing_id, | 473 int view_routing_id, |
| 451 int frame_routing_id, | 474 int frame_routing_id, |
| 452 bool swapped_out, | 475 bool swapped_out, |
| 453 bool hidden); | 476 bool hidden); |
| 454 | 477 |
| 478 // PlzNavigate | |
| 479 // Creates a new RenderFrameHost and does all required supporting work for the | |
| 480 // speculative creation of a new renderer for an ongoing navigation request. | |
| 481 // This RenderFrameHost might be later destroyed if the final navigation | |
|
nasko
2014/11/10 17:35:32
nit: swap the ordering of "later" and "destroyed"
carlosk
2014/11/13 14:40:26
Done.
| |
| 482 // destination doesn't match the initial one. | |
| 483 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
| 484 SiteInstance* old_instance, | |
| 485 SiteInstance* new_instance); | |
| 486 | |
| 487 // PlzNavigate | |
| 488 // Cleans up the date related to the speculative RenderFrameHost. | |
| 489 void CleanUpSpeculativeRenderFrameHost(); | |
| 490 | |
| 455 // Sets up the necessary state for a new RenderViewHost with the given opener, | 491 // Sets up the necessary state for a new RenderViewHost with the given opener, |
| 456 // if necessary. It creates a RenderFrameProxy in the target renderer process | 492 // if necessary. It creates a RenderFrameProxy in the target renderer process |
| 457 // with the given |proxy_routing_id|, which is used to route IPC messages when | 493 // with the given |proxy_routing_id|, which is used to route IPC messages when |
| 458 // in swapped out state. Returns early if the RenderViewHost has already been | 494 // in swapped out state. Returns early if the RenderViewHost has already been |
| 459 // initialized for another RenderFrameHost. | 495 // initialized for another RenderFrameHost. |
| 460 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 496 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
| 461 // be for the RenderFrame, since frames can have openers. | 497 // be for the RenderFrame, since frames can have openers. |
| 462 bool InitRenderView(RenderViewHostImpl* render_view_host, | 498 bool InitRenderView(RenderViewHostImpl* render_view_host, |
| 463 int opener_route_id, | 499 int opener_route_id, |
| 464 int proxy_routing_id, | 500 int proxy_routing_id, |
| 465 bool for_main_frame_navigation); | 501 bool for_main_frame_navigation); |
| 466 | 502 |
| 467 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 503 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
| 468 // above. | 504 // above. |
| 469 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 505 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
| 470 | 506 |
| 471 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 507 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
| 472 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 508 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
| 473 // since there could be Web UI switching as well. Call this for every commit. | 509 // since there could be Web UI switching as well. Call this for every commit. |
| 474 void CommitPending(); | 510 // With PlzNavigate enabled, |use_speculative_rfh| can be set to true what |
|
nasko
2014/11/10 17:35:32
nit: s/what/which/
carlosk
2014/11/13 14:40:26
Done.
| |
| 511 // will cause the speculative RenderFrameHost to be the active one. | |
| 512 void CommitPending(bool use_speculative_rfh); | |
| 475 | 513 |
| 476 // Runs the unload handler in the old RenderFrameHost, after the new | 514 // Runs the unload handler in the old RenderFrameHost, after the new |
| 477 // RenderFrameHost has committed. |old_render_frame_host| will either be | 515 // RenderFrameHost has committed. |old_render_frame_host| will either be |
| 478 // deleted or put on the pending delete list during this call. | 516 // deleted or put on the pending delete list during this call. |
| 479 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 517 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
| 480 | 518 |
| 519 // Called to properly discard a created RenderFrameHost that was never made | |
| 520 // active (for active ones SwapOutOldFrame is used instead). It can whether be | |
|
nasko
2014/11/10 17:35:32
nit: s/whether//
carlosk
2014/11/13 14:40:26
Done.
| |
| 521 // swapped out or fully destroyed. | |
| 522 void RecycleRenderFrameHost( | |
| 523 scoped_ptr<RenderFrameHostImpl> render_frame_host); | |
| 524 | |
| 481 // Holds |render_frame_host| until it can be deleted when its swap out ACK | 525 // Holds |render_frame_host| until it can be deleted when its swap out ACK |
| 482 // arrives. | 526 // arrives. |
| 483 void MoveToPendingDeleteHosts( | 527 void MoveToPendingDeleteHosts( |
| 484 scoped_ptr<RenderFrameHostImpl> render_frame_host); | 528 scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| 485 | 529 |
| 486 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to | 530 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to |
| 487 // shutdown frames when all the frames in a SiteInstance are confirmed to be | 531 // shutdown frames when all the frames in a SiteInstance are confirmed to be |
| 488 // swapped out. | 532 // swapped out. |
| 489 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); | 533 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); |
| 490 | 534 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 RFHPendingDeleteList pending_delete_hosts_; | 621 RFHPendingDeleteList pending_delete_hosts_; |
| 578 | 622 |
| 579 // The intersitial page currently shown if any, not own by this class | 623 // The intersitial page currently shown if any, not own by this class |
| 580 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 624 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 581 InterstitialPageImpl* interstitial_page_; | 625 InterstitialPageImpl* interstitial_page_; |
| 582 | 626 |
| 583 NotificationRegistrar registrar_; | 627 NotificationRegistrar registrar_; |
| 584 | 628 |
| 585 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 629 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 586 | 630 |
| 631 // PlzNavigate | |
| 632 // Members to store the speculative RFH created upon starting a navigation | |
| 633 // allowing the creation of the renderer process as early as possible. | |
| 634 // Might be discarded later on if the final URL's SiteInstance doesn't match | |
| 635 // what was assumed in the beginning. | |
| 636 // Note: speculative RenderFrameHost is only used for PlzNavigate and pending | |
| 637 // only for the regular navigation (not yet true, but will be). | |
| 638 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
| 639 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
| 640 | |
| 587 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 641 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 588 }; | 642 }; |
| 589 | 643 |
| 590 } // namespace content | 644 } // namespace content |
| 591 | 645 |
| 592 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 646 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |