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; | |
| 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; |
| 29 class FrameTreeNode; | 30 class FrameTreeNode; |
| 30 class InterstitialPageImpl; | 31 class InterstitialPageImpl; |
| 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 RenderFrameHostImpl; | 37 class RenderFrameHostImpl; |
| 37 class RenderFrameHostManagerTest; | |
|
Charlie Reis
2014/12/04 01:11:30
I'm not sure we want to delete this. It may not b
carlosk
2014/12/09 07:55:43
Done.
| |
| 38 class RenderFrameProxyHost; | 38 class RenderFrameProxyHost; |
| 39 class RenderViewHost; | 39 class RenderViewHost; |
| 40 class RenderViewHostImpl; | 40 class RenderViewHostImpl; |
| 41 class RenderWidgetHostDelegate; | 41 class RenderWidgetHostDelegate; |
| 42 class RenderWidgetHostView; | 42 class RenderWidgetHostView; |
| 43 class TestWebContents; | |
| 44 class WebUIImpl; | 43 class WebUIImpl; |
| 44 struct CommonNavigationParams; | |
| 45 | 45 |
| 46 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a | 46 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a |
| 47 // current_frame_host() which is the content currently visible to the user. When | 47 // 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 | 48 // 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 | 49 // SiteInstance), it will replace its current RenderFrameHost with a new |
| 50 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. | 50 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. |
| 51 // | 51 // |
| 52 // Cross-process navigation works like this: | 52 // Cross-process navigation works like this: |
| 53 // | 53 // |
| 54 // - RFHM::Navigate determines whether the destination is cross-site, and if so, | 54 // - RFHM::Navigate determines whether the destination is cross-site, and if so, |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 | 359 |
| 360 // Deletes any proxy hosts associated with this node. Used during destruction | 360 // Deletes any proxy hosts associated with this node. Used during destruction |
| 361 // of WebContentsImpl. | 361 // of WebContentsImpl. |
| 362 void ResetProxyHosts(); | 362 void ResetProxyHosts(); |
| 363 | 363 |
| 364 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 364 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
| 365 // that has the given SiteInstance and is associated with this | 365 // that has the given SiteInstance and is associated with this |
| 366 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 366 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 367 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 367 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 368 | 368 |
| 369 // PlzNavigate: Called when a navigation is ready to commit, to select the | 369 // PlzNavigate |
| 370 // renderer that will commit it. | 370 // Notifies the RFHM that a navigation is about to begin so that it can |
| 371 // speculatively spawn a new renderer process if needed. | |
| 372 void BeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, | |
| 373 const CommonNavigationParams& common_params); | |
| 374 | |
| 375 // PlzNavigate | |
| 376 // Called when a navigation is ready to commit, to select the renderer that | |
|
Charlie Reis
2014/12/04 01:11:32
nit: renderer -> RenderFrameHost
carlosk
2014/12/09 07:55:42
Done.
| |
| 377 // will commit it. | |
| 371 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 378 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
| 372 ui::PageTransition transition); | 379 ui::PageTransition transition); |
| 373 | 380 |
| 381 // PlzNavigate | |
| 382 // Cancels any ongoing navigation. | |
|
Charlie Reis
2014/12/04 01:11:31
nit: Cancels any state for any ongoing navigation.
carlosk
2014/12/09 07:55:42
Done.
| |
| 383 void CleanUpNavigation(); | |
| 384 | |
| 374 private: | 385 private: |
| 386 friend class NavigatorTestWithBrowserSideNavigation; | |
| 375 friend class RenderFrameHostManagerTest; | 387 friend class RenderFrameHostManagerTest; |
| 376 friend class TestWebContents; | 388 friend class TestWebContents; |
| 377 | 389 |
| 378 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 390 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
| 379 CreateCrossProcessSubframeProxies); | 391 CreateCrossProcessSubframeProxies); |
| 380 | 392 |
| 381 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 393 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
| 382 // FrameTreeNode's RenderFrameHostManager. | 394 // FrameTreeNode's RenderFrameHostManager. |
| 383 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 395 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
| 384 FrameTreeNode* node); | 396 FrameTreeNode* node); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 // route ID to be used for the new RenderView to be created. | 471 // route ID to be used for the new RenderView to be created. |
| 460 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, | 472 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
| 461 SiteInstance* new_instance); | 473 SiteInstance* new_instance); |
| 462 | 474 |
| 463 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 475 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| 464 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 476 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| 465 int view_routing_id, | 477 int view_routing_id, |
| 466 int frame_routing_id, | 478 int frame_routing_id, |
| 467 int flags); | 479 int flags); |
| 468 | 480 |
| 481 // PlzNavigate | |
| 482 // Creates a new RenderFrameHost and does all required supporting work for the | |
| 483 // speculative creation of a new renderer for an ongoing navigation request. | |
|
Charlie Reis
2014/12/04 01:11:31
creation of a new speculative RenderFrameHost for.
carlosk
2014/12/09 07:55:42
Done.
| |
| 484 // This RenderFrameHost might be destroyed later if the final navigation | |
| 485 // destination doesn't match the initial one. | |
| 486 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
| 487 SiteInstance* old_instance, | |
| 488 SiteInstance* new_instance, | |
| 489 int bindings); | |
| 490 | |
| 469 // 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, |
| 470 // if necessary. It creates a RenderFrameProxy in the target renderer process | 492 // if necessary. It creates a RenderFrameProxy in the target renderer process |
| 471 // 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 |
| 472 // 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 |
| 473 // initialized for another RenderFrameHost. | 495 // initialized for another RenderFrameHost. |
| 474 // 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 |
| 475 // be for the RenderFrame, since frames can have openers. | 497 // be for the RenderFrame, since frames can have openers. |
| 476 bool InitRenderView(RenderViewHostImpl* render_view_host, | 498 bool InitRenderView(RenderViewHostImpl* render_view_host, |
| 477 int opener_route_id, | 499 int opener_route_id, |
| 478 int proxy_routing_id, | 500 int proxy_routing_id, |
| 479 bool for_main_frame_navigation); | 501 bool for_main_frame_navigation); |
| 480 | 502 |
| 481 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 503 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
| 482 // above. | 504 // above. |
| 483 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 505 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
| 484 | 506 |
| 485 // 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 |
| 486 // 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, |
| 487 // 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. |
| 510 // If PlzNavigate is enabled the method will set the speculative | |
| 511 // RenderFrameHost to be the active one instead of the pending. | |
|
Charlie Reis
2014/12/04 01:11:31
nit: set the speculative (not pending) RenderFrame
carlosk
2014/12/09 07:55:43
Done.
| |
| 488 void CommitPending(); | 512 void CommitPending(); |
| 489 | 513 |
| 490 // Runs the unload handler in the old RenderFrameHost, after the new | 514 // Runs the unload handler in the old RenderFrameHost, after the new |
| 491 // RenderFrameHost has committed. |old_render_frame_host| will either be | 515 // RenderFrameHost has committed. |old_render_frame_host| will either be |
| 492 // deleted or put on the pending delete list during this call. | 516 // deleted or put on the pending delete list during this call. |
| 493 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 517 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
| 494 | 518 |
| 495 // Discards a RenderFrameHost that was never made active (for active ones | 519 // Discards a RenderFrameHost that was never made active (for active ones |
| 496 // SwapOutOldFrame is used instead). | 520 // SwapOutOldFrame is used instead). |
| 497 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); | 521 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 // A RenderFrameHost used to load a cross-site page. This remains hidden | 583 // A RenderFrameHost used to load a cross-site page. This remains hidden |
| 560 // while a cross-site request is pending until it calls DidNavigate. It may | 584 // while a cross-site request is pending until it calls DidNavigate. It may |
| 561 // have an associated Web UI, in which case the Web UI pointer will be non- | 585 // have an associated Web UI, in which case the Web UI pointer will be non- |
| 562 // NULL. | 586 // NULL. |
| 563 // | 587 // |
| 564 // The |pending_web_ui_| may be non-NULL even when the | 588 // The |pending_web_ui_| may be non-NULL even when the |
| 565 // |pending_render_frame_host_| is NULL. This will happen when we're | 589 // |pending_render_frame_host_| is NULL. This will happen when we're |
| 566 // transitioning between two Web UI pages: the RFH won't be swapped, so the | 590 // transitioning between two Web UI pages: the RFH won't be swapped, so the |
| 567 // pending pointer will be unused, but there will be a pending Web UI | 591 // pending pointer will be unused, but there will be a pending Web UI |
| 568 // associated with the navigation. | 592 // associated with the navigation. |
| 569 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; | 593 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; |
|
Charlie Reis
2014/12/04 01:11:31
Let's add:
Note: This is not used in PlzNavigate.
carlosk
2014/12/09 07:55:42
Done.
| |
| 570 | 594 |
| 571 // If a pending request needs to be transferred to another process, this | 595 // If a pending request needs to be transferred to another process, this |
| 572 // owns the request until it's transferred to the new process, so it will be | 596 // owns the request until it's transferred to the new process, so it will be |
| 573 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. | 597 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. |
| 574 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; | 598 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; |
| 575 | 599 |
| 576 // Tracks information about any navigation paused after receiving response | 600 // Tracks information about any navigation paused after receiving response |
| 577 // headers. | 601 // headers. |
| 578 scoped_ptr<GlobalRequestID> response_started_id_; | 602 scoped_ptr<GlobalRequestID> response_started_id_; |
| 579 | 603 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 593 // because sets don't appear to support linked_ptrs. | 617 // because sets don't appear to support linked_ptrs. |
| 594 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; | 618 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; |
| 595 RFHPendingDeleteList pending_delete_hosts_; | 619 RFHPendingDeleteList pending_delete_hosts_; |
| 596 | 620 |
| 597 // The intersitial page currently shown if any, not own by this class | 621 // The intersitial page currently shown if any, not own by this class |
| 598 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 622 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 599 InterstitialPageImpl* interstitial_page_; | 623 InterstitialPageImpl* interstitial_page_; |
| 600 | 624 |
| 601 NotificationRegistrar registrar_; | 625 NotificationRegistrar registrar_; |
| 602 | 626 |
| 603 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 627 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
|
Charlie Reis
2014/12/04 01:11:30
WeakPtrFactories always have to be the last member
carlosk
2014/12/09 07:55:42
Done.
| |
| 604 | 628 |
| 629 // PlzNavigate | |
| 630 // Members to store the speculative RFH created upon starting a navigation | |
| 631 // allowing the creation of the renderer process as early as possible. | |
|
Charlie Reis
2014/12/04 21:46:28
This first sentence is a bit awkward. Maybe simpl
carlosk
2014/12/09 07:55:42
Done.
| |
| 632 // The created instance might be discarded later on if the final URL's | |
| 633 // SiteInstance isn't compatible with what was used to create it. | |
| 634 // Note: speculative RenderFrameHost is only used for PlzNavigate and the | |
| 635 // pending one only for the regular navigation. | |
|
Charlie Reis
2014/12/04 01:11:32
"for the regular navigation" is a bit awkward. Ma
carlosk
2014/12/09 07:55:42
Done.
| |
| 636 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
| 637 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
| 638 | |
| 639 // PlzNavigate | |
| 640 // If true at navigation commit time the current WebUI will be kept instead of | |
| 641 // creating a new one. | |
| 642 bool should_reuse_web_ui_; | |
| 643 | |
| 605 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 644 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 606 }; | 645 }; |
| 607 | 646 |
| 608 } // namespace content | 647 } // namespace content |
| 609 | 648 |
| 610 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 649 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |