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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 RenderFrameHostImpl* pending_render_frame_host); | 284 RenderFrameHostImpl* pending_render_frame_host); |
283 | 285 |
284 // Resume navigation paused after receiving response headers. | 286 // Resume navigation paused after receiving response headers. |
285 void ResumeResponseDeferredAtStart(); | 287 void ResumeResponseDeferredAtStart(); |
286 | 288 |
287 // Clear navigation transition data. | 289 // Clear navigation transition data. |
288 void ClearNavigationTransitionData(); | 290 void ClearNavigationTransitionData(); |
289 | 291 |
290 // Called when a renderer's frame navigates. | 292 // Called when a renderer's frame navigates. |
291 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host, | 293 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host, |
292 bool was_caused_by_user_gesture); | 294 bool was_caused_by_user_gesture, |
295 bool was_within_same_page); | |
nasko
2015/01/06 00:03:18
Why is this parameter added? It isn't used anywher
carlosk
2015/01/08 16:05:56
clamy@ asked for this to be added to be already in
nasko
2015/01/09 18:13:07
In general, we don't add code that isn't used in a
carlosk
2015/01/12 14:35:25
Talked to clamy@ and we agreed to revert it.
| |
293 | 296 |
294 // Called when a renderer sets its opener to null. | 297 // Called when a renderer sets its opener to null. |
295 void DidDisownOpener(RenderFrameHost* render_frame_host); | 298 void DidDisownOpener(RenderFrameHost* render_frame_host); |
296 | 299 |
297 // Sets the pending Web UI for the pending navigation, ensuring that the | 300 // Sets the pending Web UI for the pending navigation, ensuring that the |
298 // bindings are appropriate compared to |bindings|. | 301 // bindings are appropriate compared to |bindings|. |
299 void SetPendingWebUI(const GURL& url, int bindings); | 302 void SetPendingWebUI(const GURL& url, int bindings); |
300 | 303 |
301 // Creates and initializes a RenderFrameHost. The |web_ui| is an optional | 304 // Creates and initializes a RenderFrameHost. The |web_ui| is an optional |
302 // input parameter used to double check bindings when swapping back in a | 305 // input parameter used to double check bindings when swapping back in a |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 | 363 |
361 // Deletes any proxy hosts associated with this node. Used during destruction | 364 // Deletes any proxy hosts associated with this node. Used during destruction |
362 // of WebContentsImpl. | 365 // of WebContentsImpl. |
363 void ResetProxyHosts(); | 366 void ResetProxyHosts(); |
364 | 367 |
365 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 368 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
366 // that has the given SiteInstance and is associated with this | 369 // that has the given SiteInstance and is associated with this |
367 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 370 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
368 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 371 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
369 | 372 |
370 // PlzNavigate: Called when a navigation is ready to commit, to select the | 373 // PlzNavigate |
371 // renderer that will commit it. | 374 // Notifies the RFHM that a navigation has begun so that it can speculatively |
372 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 375 // create a new renderer process if needed. |
nasko
2015/01/06 00:03:18
Why renaming from Get to Select? Select implies re
carlosk
2015/01/08 16:05:56
I discussed with clamy@ and this seemed like the b
nasko
2015/01/08 23:36:37
While somewhat true, there is a coding convention
carlosk
2015/01/09 14:48:52
Acknowledged. Reverted to "Get".
|
nasko
2015/01/06 00:03:18
nit: s/a new renderer process/a new RenderFrameHos
carlosk
2015/01/08 16:05:56
Done.
|
373 ui::PageTransition transition); | 376 void BeginNavigation(const CommonNavigationParams& common_params); |
377 | |
378 // PlzNavigate | |
379 // Called (possibly several times) during a navigation to select an | |
nasko
2015/01/06 00:03:18
Do we really expect this to be called more than tw
carlosk
2015/01/08 16:05:56
For every redirect once we begin monitoring them.
nasko
2015/01/08 23:36:37
Why do we need to monitor redirects? We should be
carlosk
2015/01/09 14:48:52
This is a performance improvement change and the e
nasko
2015/01/09 18:13:07
I'm sorry, but I do not agree with this. While it
carlosk
2015/01/12 14:35:25
I agree that backing this with data is the right t
| |
380 // appropriate RenderFrameHost for the provided URL. | |
381 RenderFrameHostImpl* SelectFrameHostForNavigation( | |
382 const GURL& url, | |
383 ui::PageTransition transition); | |
384 | |
385 // PlzNavigate | |
386 // Cancels any state for any ongoing navigation. | |
nasko
2015/01/06 00:03:18
nit: State cannot be cancelled, it can be cleaned
carlosk
2015/01/08 16:05:56
Changed to Clean up.
| |
387 void CleanUpNavigation(); | |
388 | |
389 // PlzNavigate | |
390 // Clears the speculative members, returning the RenderFrameHost to the caller | |
391 // for disposal. | |
392 scoped_ptr<RenderFrameHostImpl> UnsetSpeculativeRenderFrameHost(); | |
374 | 393 |
375 // Notification methods to tell this RenderFrameHostManager that the frame it | 394 // Notification methods to tell this RenderFrameHostManager that the frame it |
376 // is responsible for has started or stopped loading a document. | 395 // is responsible for has started or stopped loading a document. |
377 void OnDidStartLoading(); | 396 void OnDidStartLoading(); |
378 void OnDidStopLoading(); | 397 void OnDidStopLoading(); |
379 | 398 |
380 private: | 399 private: |
400 friend class NavigatorTestWithBrowserSideNavigation; | |
381 friend class RenderFrameHostManagerTest; | 401 friend class RenderFrameHostManagerTest; |
382 friend class TestWebContents; | 402 friend class TestWebContents; |
383 | 403 |
384 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 404 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
385 CreateCrossProcessSubframeProxies); | 405 CreateCrossProcessSubframeProxies); |
386 | 406 |
387 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 407 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
388 // FrameTreeNode's RenderFrameHostManager. | 408 // FrameTreeNode's RenderFrameHostManager. |
389 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 409 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
390 FrameTreeNode* node); | 410 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. | 491 // route ID to be used for the new RenderView to be created. |
472 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, | 492 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
473 SiteInstance* new_instance); | 493 SiteInstance* new_instance); |
474 | 494 |
475 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 495 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
476 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 496 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
477 int view_routing_id, | 497 int view_routing_id, |
478 int frame_routing_id, | 498 int frame_routing_id, |
479 int flags); | 499 int flags); |
480 | 500 |
501 // PlzNavigate | |
502 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an | |
503 // ongoing navigation. They might be destroyed and re-created later if the | |
504 // navigation is redirected to a different site. | |
nasko
2015/01/06 00:03:18
nit: s/site/SiteInstance/
carlosk
2015/01/08 16:05:56
Done.
| |
505 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
506 SiteInstance* old_instance, | |
507 SiteInstance* new_instance, | |
508 int bindings); | |
509 | |
481 // Sets up the necessary state for a new RenderViewHost with the given opener, | 510 // 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 | 511 // 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 | 512 // 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 | 513 // in swapped out state. Returns early if the RenderViewHost has already been |
485 // initialized for another RenderFrameHost. | 514 // initialized for another RenderFrameHost. |
486 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 515 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
487 // be for the RenderFrame, since frames can have openers. | 516 // be for the RenderFrame, since frames can have openers. |
488 bool InitRenderView(RenderViewHostImpl* render_view_host, | 517 bool InitRenderView(RenderViewHostImpl* render_view_host, |
489 int opener_route_id, | 518 int opener_route_id, |
490 int proxy_routing_id, | 519 int proxy_routing_id, |
491 bool for_main_frame_navigation); | 520 bool for_main_frame_navigation); |
492 | 521 |
493 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 522 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
494 // above. | 523 // above. |
495 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 524 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
496 | 525 |
497 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 526 // 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, | 527 // 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. | 528 // since there could be Web UI switching as well. Call this for every commit. |
529 // If PlzNavigate is enabled the method will set the speculative (not pending) | |
530 // RenderFrameHost to be the active one. | |
500 void CommitPending(); | 531 void CommitPending(); |
501 | 532 |
502 // Runs the unload handler in the old RenderFrameHost, after the new | 533 // Runs the unload handler in the old RenderFrameHost, after the new |
503 // RenderFrameHost has committed. |old_render_frame_host| will either be | 534 // RenderFrameHost has committed. |old_render_frame_host| will either be |
504 // deleted or put on the pending delete list during this call. | 535 // deleted or put on the pending delete list during this call. |
505 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 536 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
506 | 537 |
507 // Discards a RenderFrameHost that was never made active (for active ones | 538 // Discards a RenderFrameHost that was never made active (for active ones |
508 // SwapOutOldFrame is used instead). | 539 // SwapOutOldFrame is used instead). |
509 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); | 540 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 | 607 // 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 | 608 // 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- | 609 // have an associated Web UI, in which case the Web UI pointer will be non- |
579 // NULL. | 610 // NULL. |
580 // | 611 // |
581 // The |pending_web_ui_| may be non-NULL even when the | 612 // The |pending_web_ui_| may be non-NULL even when the |
582 // |pending_render_frame_host_| is NULL. This will happen when we're | 613 // |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 | 614 // 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 | 615 // pending pointer will be unused, but there will be a pending Web UI |
585 // associated with the navigation. | 616 // associated with the navigation. |
617 // Note: This is not used in PlzNavigate. | |
586 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; | 618 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; |
587 | 619 |
588 // If a pending request needs to be transferred to another process, this | 620 // 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 | 621 // 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. | 622 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. |
591 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; | 623 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; |
592 | 624 |
593 // Tracks information about any navigation paused after receiving response | 625 // Tracks information about any navigation paused after receiving response |
594 // headers. | 626 // headers. |
595 scoped_ptr<GlobalRequestID> response_started_id_; | 627 scoped_ptr<GlobalRequestID> response_started_id_; |
596 | 628 |
597 // If either of these is non-NULL, the pending navigation is to a chrome: | 629 // 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 | 630 // 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 | 631 // used for when they reference the same object. If either is non-NULL, the |
600 // other should be NULL. | 632 // other should be NULL. |
633 // Note: These are not used in PlzNavigate. | |
601 scoped_ptr<WebUIImpl> pending_web_ui_; | 634 scoped_ptr<WebUIImpl> pending_web_ui_; |
602 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; | 635 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
603 | 636 |
604 // A map of site instance ID to RenderFrameProxyHosts. | 637 // A map of site instance ID to RenderFrameProxyHosts. |
605 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; | 638 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; |
606 RenderFrameProxyHostMap proxy_hosts_; | 639 RenderFrameProxyHostMap proxy_hosts_; |
607 | 640 |
608 // A list of RenderFrameHosts waiting to shut down after swapping out. We use | 641 // 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 | 642 // a linked list since we expect frequent deletes and no indexed access, and |
610 // because sets don't appear to support linked_ptrs. | 643 // because sets don't appear to support linked_ptrs. |
611 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; | 644 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; |
612 RFHPendingDeleteList pending_delete_hosts_; | 645 RFHPendingDeleteList pending_delete_hosts_; |
613 | 646 |
614 // The intersitial page currently shown if any, not own by this class | 647 // The intersitial page currently shown if any, not own by this class |
615 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 648 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
616 InterstitialPageImpl* interstitial_page_; | 649 InterstitialPageImpl* interstitial_page_; |
617 | 650 |
618 NotificationRegistrar registrar_; | 651 NotificationRegistrar registrar_; |
619 | 652 |
653 // PlzNavigate | |
654 // These members store a speculative RenderFrameHost and WebUI. They are | |
655 // created early in a navigation so the renderer process can be started in | |
nasko
2015/01/06 00:03:18
nit: s/the renderer process/a renderer process/
s/
carlosk
2015/01/08 16:05:56
Done.
| |
656 // parallel. This is purely a performance optimization and is not required for | |
657 // correct behavior. The created RenderFrameHost might be discarded later on | |
658 // if the final URL's SiteInstance isn't compatible with what was used to | |
659 // create it. | |
660 // Note: PlzNavigate only uses speculative RenderFrameHost and WebUI, not | |
661 // the pending ones. | |
662 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
663 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
664 | |
665 // PlzNavigate | |
666 // If true at navigation commit time the current WebUI will be kept instead of | |
667 // creating a new one. | |
668 bool should_reuse_web_ui_; | |
669 | |
620 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 670 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
621 | 671 |
622 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 672 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
623 }; | 673 }; |
624 | 674 |
625 } // namespace content | 675 } // namespace content |
626 | 676 |
627 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 677 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |