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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class BrowserContext; | 26 class BrowserContext; |
| 27 class CrossProcessFrameConnector; | 27 class CrossProcessFrameConnector; |
| 28 class CrossSiteTransferringRequest; | 28 class CrossSiteTransferringRequest; |
| 29 class FrameTreeNode; | 29 class FrameTreeNode; |
| 30 class InterstitialPageImpl; | 30 class InterstitialPageImpl; |
| 31 class NavigationControllerImpl; | 31 class NavigationControllerImpl; |
| 32 class NavigationEntry; | 32 class NavigationEntry; |
| 33 class NavigationEntryImpl; | 33 class NavigationEntryImpl; |
| 34 class NavigatorTestWithBrowserSideNavigation; | |
| 34 class RenderFrameHost; | 35 class RenderFrameHost; |
| 35 class RenderFrameHostDelegate; | 36 class RenderFrameHostDelegate; |
| 36 class RenderFrameHostImpl; | 37 class RenderFrameHostImpl; |
| 37 class RenderFrameHostManagerTest; | 38 class RenderFrameHostManagerTest; |
| 38 class RenderFrameProxyHost; | 39 class RenderFrameProxyHost; |
| 39 class RenderViewHost; | 40 class RenderViewHost; |
| 40 class RenderViewHostImpl; | 41 class RenderViewHostImpl; |
| 41 class RenderWidgetHostDelegate; | 42 class RenderWidgetHostDelegate; |
| 42 class RenderWidgetHostView; | 43 class RenderWidgetHostView; |
| 43 class TestWebContents; | 44 class TestWebContents; |
| 44 class WebUIImpl; | 45 class WebUIImpl; |
| 46 struct CommonNavigationParams; | |
| 45 | 47 |
| 46 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a | 48 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a |
| 47 // 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 |
| 48 // 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 |
| 49 // SiteInstance), it will replace its current RenderFrameHost with a new | 51 // SiteInstance), it will replace its current RenderFrameHost with a new |
| 50 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. | 52 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. |
| 51 // | 53 // |
| 52 // Cross-process navigation works like this: | 54 // Cross-process navigation works like this: |
| 53 // | 55 // |
| 54 // - 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 | 362 |
| 361 // Deletes any proxy hosts associated with this node. Used during destruction | 363 // Deletes any proxy hosts associated with this node. Used during destruction |
| 362 // of WebContentsImpl. | 364 // of WebContentsImpl. |
| 363 void ResetProxyHosts(); | 365 void ResetProxyHosts(); |
| 364 | 366 |
| 365 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 367 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
| 366 // that has the given SiteInstance and is associated with this | 368 // that has the given SiteInstance and is associated with this |
| 367 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 369 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 368 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 370 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 369 | 371 |
| 370 // PlzNavigate: Called when a navigation is ready to commit, to select the | 372 // PlzNavigate |
| 371 // renderer that will commit it. | 373 // Notifies the RFHM that a navigation has begun so that it can speculatively |
| 374 // create a new RenderFrameHost (and potentially a new process) if needed. | |
| 375 void BeginNavigation(const CommonNavigationParams& common_params); | |
| 376 | |
| 377 // PlzNavigate | |
| 378 // Called (possibly several times) during a navigation to select an | |
|
Charlie Reis
2015/01/12 23:30:53
nit: select or create
carlosk
2015/01/13 15:54:13
Done.
| |
| 379 // appropriate RenderFrameHost for the provided URL. | |
| 372 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 380 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
|
Charlie Reis
2015/01/12 23:30:53
The ownership of this RFH is unclear. Please docu
carlosk
2015/01/13 15:54:13
Done.
| |
| 373 ui::PageTransition transition); | 381 ui::PageTransition transition); |
| 374 | 382 |
| 383 // PlzNavigate | |
| 384 // Clean up any state for any ongoing navigation. | |
| 385 void CleanUpNavigation(); | |
| 386 | |
| 387 // PlzNavigate | |
| 388 // Clears the speculative members, returning the RenderFrameHost to the caller | |
| 389 // for disposal. | |
| 390 scoped_ptr<RenderFrameHostImpl> UnsetSpeculativeRenderFrameHost(); | |
| 391 | |
| 375 // Notification methods to tell this RenderFrameHostManager that the frame it | 392 // Notification methods to tell this RenderFrameHostManager that the frame it |
| 376 // is responsible for has started or stopped loading a document. | 393 // is responsible for has started or stopped loading a document. |
| 377 void OnDidStartLoading(); | 394 void OnDidStartLoading(); |
| 378 void OnDidStopLoading(); | 395 void OnDidStopLoading(); |
| 379 | 396 |
| 380 private: | 397 private: |
| 398 friend class NavigatorTestWithBrowserSideNavigation; | |
| 381 friend class RenderFrameHostManagerTest; | 399 friend class RenderFrameHostManagerTest; |
| 382 friend class TestWebContents; | 400 friend class TestWebContents; |
| 383 | 401 |
| 384 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 402 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
| 385 CreateCrossProcessSubframeProxies); | 403 CreateCrossProcessSubframeProxies); |
| 386 | 404 |
| 387 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 405 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
| 388 // FrameTreeNode's RenderFrameHostManager. | 406 // FrameTreeNode's RenderFrameHostManager. |
| 389 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 407 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
| 390 FrameTreeNode* node); | 408 FrameTreeNode* node); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 // route ID to be used for the new RenderView to be created. | 489 // route ID to be used for the new RenderView to be created. |
| 472 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, | 490 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
| 473 SiteInstance* new_instance); | 491 SiteInstance* new_instance); |
| 474 | 492 |
| 475 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 493 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| 476 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 494 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| 477 int view_routing_id, | 495 int view_routing_id, |
| 478 int frame_routing_id, | 496 int frame_routing_id, |
| 479 int flags); | 497 int flags); |
| 480 | 498 |
| 499 // PlzNavigate | |
| 500 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an | |
| 501 // ongoing navigation. They might be destroyed and re-created later if the | |
| 502 // navigation is redirected to a different SiteInstance. | |
| 503 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
| 504 SiteInstance* old_instance, | |
| 505 SiteInstance* new_instance, | |
| 506 int bindings); | |
| 507 | |
| 481 // Sets up the necessary state for a new RenderViewHost with the given opener, | 508 // Sets up the necessary state for a new RenderViewHost with the given opener, |
| 482 // if necessary. It creates a RenderFrameProxy in the target renderer process | 509 // if necessary. It creates a RenderFrameProxy in the target renderer process |
| 483 // with the given |proxy_routing_id|, which is used to route IPC messages when | 510 // with the given |proxy_routing_id|, which is used to route IPC messages when |
| 484 // in swapped out state. Returns early if the RenderViewHost has already been | 511 // in swapped out state. Returns early if the RenderViewHost has already been |
| 485 // initialized for another RenderFrameHost. | 512 // initialized for another RenderFrameHost. |
| 486 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 513 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
| 487 // be for the RenderFrame, since frames can have openers. | 514 // be for the RenderFrame, since frames can have openers. |
| 488 bool InitRenderView(RenderViewHostImpl* render_view_host, | 515 bool InitRenderView(RenderViewHostImpl* render_view_host, |
| 489 int opener_route_id, | 516 int opener_route_id, |
| 490 int proxy_routing_id, | 517 int proxy_routing_id, |
| 491 bool for_main_frame_navigation); | 518 bool for_main_frame_navigation); |
| 492 | 519 |
| 493 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 520 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
| 494 // above. | 521 // above. |
| 495 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 522 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
| 496 | 523 |
| 497 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 524 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
| 498 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 525 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
| 499 // since there could be Web UI switching as well. Call this for every commit. | 526 // since there could be Web UI switching as well. Call this for every commit. |
| 527 // If PlzNavigate is enabled the method will set the speculative (not pending) | |
| 528 // RenderFrameHost to be the active one. | |
| 500 void CommitPending(); | 529 void CommitPending(); |
| 501 | 530 |
| 502 // Runs the unload handler in the old RenderFrameHost, after the new | 531 // Runs the unload handler in the old RenderFrameHost, after the new |
| 503 // RenderFrameHost has committed. |old_render_frame_host| will either be | 532 // RenderFrameHost has committed. |old_render_frame_host| will either be |
| 504 // deleted or put on the pending delete list during this call. | 533 // deleted or put on the pending delete list during this call. |
| 505 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 534 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
| 506 | 535 |
| 507 // Discards a RenderFrameHost that was never made active (for active ones | 536 // Discards a RenderFrameHost that was never made active (for active ones |
| 508 // SwapOutOldFrame is used instead). | 537 // SwapOutOldFrame is used instead). |
| 509 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); | 538 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 // A RenderFrameHost used to load a cross-site page. This remains hidden | 605 // A RenderFrameHost used to load a cross-site page. This remains hidden |
| 577 // while a cross-site request is pending until it calls DidNavigate. It may | 606 // while a cross-site request is pending until it calls DidNavigate. It may |
| 578 // have an associated Web UI, in which case the Web UI pointer will be non- | 607 // have an associated Web UI, in which case the Web UI pointer will be non- |
| 579 // NULL. | 608 // NULL. |
| 580 // | 609 // |
| 581 // The |pending_web_ui_| may be non-NULL even when the | 610 // The |pending_web_ui_| may be non-NULL even when the |
| 582 // |pending_render_frame_host_| is NULL. This will happen when we're | 611 // |pending_render_frame_host_| is NULL. This will happen when we're |
| 583 // transitioning between two Web UI pages: the RFH won't be swapped, so the | 612 // transitioning between two Web UI pages: the RFH won't be swapped, so the |
| 584 // pending pointer will be unused, but there will be a pending Web UI | 613 // pending pointer will be unused, but there will be a pending Web UI |
| 585 // associated with the navigation. | 614 // associated with the navigation. |
| 615 // Note: This is not used in PlzNavigate. | |
| 586 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; | 616 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; |
| 587 | 617 |
| 588 // If a pending request needs to be transferred to another process, this | 618 // If a pending request needs to be transferred to another process, this |
| 589 // owns the request until it's transferred to the new process, so it will be | 619 // owns the request until it's transferred to the new process, so it will be |
| 590 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. | 620 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. |
| 591 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; | 621 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; |
| 592 | 622 |
| 593 // Tracks information about any navigation paused after receiving response | 623 // Tracks information about any navigation paused after receiving response |
| 594 // headers. | 624 // headers. |
| 595 scoped_ptr<GlobalRequestID> response_started_id_; | 625 scoped_ptr<GlobalRequestID> response_started_id_; |
| 596 | 626 |
| 597 // If either of these is non-NULL, the pending navigation is to a chrome: | 627 // If either of these is non-NULL, the pending navigation is to a chrome: |
| 598 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is | 628 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is |
| 599 // used for when they reference the same object. If either is non-NULL, the | 629 // used for when they reference the same object. If either is non-NULL, the |
| 600 // other should be NULL. | 630 // other should be NULL. |
| 631 // Note: These are not used in PlzNavigate. | |
| 601 scoped_ptr<WebUIImpl> pending_web_ui_; | 632 scoped_ptr<WebUIImpl> pending_web_ui_; |
| 602 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; | 633 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
| 603 | 634 |
| 604 // A map of site instance ID to RenderFrameProxyHosts. | 635 // A map of site instance ID to RenderFrameProxyHosts. |
| 605 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; | 636 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; |
| 606 RenderFrameProxyHostMap proxy_hosts_; | 637 RenderFrameProxyHostMap proxy_hosts_; |
| 607 | 638 |
| 608 // A list of RenderFrameHosts waiting to shut down after swapping out. We use | 639 // A list of RenderFrameHosts waiting to shut down after swapping out. We use |
| 609 // a linked list since we expect frequent deletes and no indexed access, and | 640 // a linked list since we expect frequent deletes and no indexed access, and |
| 610 // because sets don't appear to support linked_ptrs. | 641 // because sets don't appear to support linked_ptrs. |
| 611 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; | 642 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; |
| 612 RFHPendingDeleteList pending_delete_hosts_; | 643 RFHPendingDeleteList pending_delete_hosts_; |
| 613 | 644 |
| 614 // The intersitial page currently shown if any, not own by this class | 645 // The intersitial page currently shown if any, not own by this class |
| 615 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 646 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 616 InterstitialPageImpl* interstitial_page_; | 647 InterstitialPageImpl* interstitial_page_; |
| 617 | 648 |
| 618 NotificationRegistrar registrar_; | 649 NotificationRegistrar registrar_; |
| 619 | 650 |
| 651 // PlzNavigate | |
| 652 // These members store a speculative RenderFrameHost and WebUI. They are | |
| 653 // created early in a navigation so a renderer process can be started in | |
| 654 // parallel, if needed. This is purely a performance optimization and is not | |
| 655 // required for correct behavior. The created RenderFrameHost might be | |
| 656 // discarded later on if the final URL's SiteInstance isn't compatible with | |
| 657 // what was used to create it. | |
| 658 // Note: PlzNavigate only uses speculative RenderFrameHost and WebUI, not | |
| 659 // the pending ones. | |
| 660 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
| 661 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
| 662 | |
| 663 // PlzNavigate | |
| 664 // If true at navigation commit time the current WebUI will be kept instead of | |
| 665 // creating a new one. | |
| 666 bool should_reuse_web_ui_; | |
| 667 | |
| 620 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 668 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 621 | 669 |
| 622 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 670 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 623 }; | 671 }; |
| 624 | 672 |
| 625 } // namespace content | 673 } // namespace content |
| 626 | 674 |
| 627 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 675 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |