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 FrameMsg_Navigate_Params; | 23 struct FrameMsg_Navigate_Params; |
24 | 24 |
25 namespace { | |
26 struct SiteInstanceDescriptor; | |
carlosk
2015/03/23 14:31:18
Instead of the lose |out_params| I preferred creat
clamy
2015/03/23 15:26:44
Unnamed namespaces are forbidden in header files.
carlosk
2015/03/23 17:39:19
Done.
| |
27 } | |
28 | |
25 namespace content { | 29 namespace content { |
26 class BrowserContext; | 30 class BrowserContext; |
27 class CrossProcessFrameConnector; | 31 class CrossProcessFrameConnector; |
28 class CrossSiteTransferringRequest; | 32 class CrossSiteTransferringRequest; |
29 class FrameTreeNode; | 33 class FrameTreeNode; |
30 class InterstitialPageImpl; | 34 class InterstitialPageImpl; |
31 class NavigationControllerImpl; | 35 class NavigationControllerImpl; |
32 class NavigationEntry; | 36 class NavigationEntry; |
33 class NavigationEntryImpl; | 37 class NavigationEntryImpl; |
34 class NavigationRequest; | 38 class NavigationRequest; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 | 419 |
416 void EnsureRenderViewInitialized(FrameTreeNode* source, | 420 void EnsureRenderViewInitialized(FrameTreeNode* source, |
417 RenderViewHostImpl* render_view_host, | 421 RenderViewHostImpl* render_view_host, |
418 SiteInstance* instance); | 422 SiteInstance* instance); |
419 | 423 |
420 private: | 424 private: |
421 friend class NavigatorTestWithBrowserSideNavigation; | 425 friend class NavigatorTestWithBrowserSideNavigation; |
422 friend class RenderFrameHostManagerTest; | 426 friend class RenderFrameHostManagerTest; |
423 friend class TestWebContents; | 427 friend class TestWebContents; |
424 | 428 |
429 enum RenderFrameHostToUse { | |
clamy
2015/03/23 15:26:44
This should be prefixed by a PlzNavigate comment t
carlosk
2015/03/23 17:39:19
Done. I also moved the friend-related macro below
| |
430 INVALID, | |
431 REUSE_CURRENT, | |
432 NEW_SPECULATIVE, | |
433 REUSE_SPECULATIVE, | |
434 }; | |
435 | |
425 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 436 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
426 CreateCrossProcessSubframeProxies); | 437 CreateCrossProcessSubframeProxies); |
427 | 438 |
428 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 439 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
429 // FrameTreeNode's RenderFrameHostManager. | 440 // FrameTreeNode's RenderFrameHostManager. |
430 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 441 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
431 FrameTreeNode* node); | 442 FrameTreeNode* node); |
432 // Used with FrameTree::ForEach to reset initialized state of | 443 // Used with FrameTree::ForEach to reset initialized state of |
433 // RenderFrameProxyHosts from a FrameTreeNode's RenderFrameHostManager. | 444 // RenderFrameProxyHosts from a FrameTreeNode's RenderFrameHostManager. |
434 static bool ResetProxiesInSiteInstance(int32 site_instance_id, | 445 static bool ResetProxiesInSiteInstance(int32 site_instance_id, |
(...skipping 27 matching lines...) Expand all Loading... | |
462 // Creates a new Web UI, ensuring that the bindings are appropriate compared | 473 // Creates a new Web UI, ensuring that the bindings are appropriate compared |
463 // to |bindings|. | 474 // to |bindings|. |
464 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& url, int bindings); | 475 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& url, int bindings); |
465 | 476 |
466 // Returns true if it is safe to reuse the current WebUI when navigating from | 477 // Returns true if it is safe to reuse the current WebUI when navigating from |
467 // |current_entry| to |new_url|. | 478 // |current_entry| to |new_url|. |
468 bool ShouldReuseWebUI( | 479 bool ShouldReuseWebUI( |
469 const NavigationEntry* current_entry, | 480 const NavigationEntry* current_entry, |
470 const GURL& new_url) const; | 481 const GURL& new_url) const; |
471 | 482 |
483 // PlzNavigate | |
484 // Returns which RenderFrameHost should be used for the navigation among the | |
485 // possibilities defined by RenderFrameHostToUse. | |
486 scoped_refptr<SiteInstance> ChooseFrameHostForNavigation( | |
487 const NavigationRequest& request, | |
488 RenderFrameHostToUse* rfh_to_use); | |
carlosk
2015/03/23 14:31:18
The added logic to reuse the speculative RFH made
clamy
2015/03/23 15:26:44
I don't like the signature of this method either,
carlosk
2015/03/23 17:39:19
What I think is nice about the two methods is that
| |
489 | |
472 // Returns the SiteInstance to use for the navigation. | 490 // Returns the SiteInstance to use for the navigation. |
473 SiteInstance* GetSiteInstanceForNavigation(const GURL& dest_url, | 491 SiteInstance* GetSiteInstanceForNavigation(const GURL& dest_url, |
clamy
2015/03/23 15:26:44
Is GetSiteInstanceForNavigation idempotent in the
carlosk
2015/03/23 17:39:19
GetSiteInstanceForNavigation is not idempotent as
| |
474 SiteInstance* source_instance, | 492 SiteInstance* source_instance, |
475 SiteInstance* dest_instance, | 493 SiteInstance* dest_instance, |
476 ui::PageTransition transition, | 494 ui::PageTransition transition, |
477 bool dest_is_restore, | 495 bool dest_is_restore, |
478 bool dest_is_view_source_mode); | 496 bool dest_is_view_source_mode); |
479 | 497 |
480 // Returns an appropriate SiteInstance object for the given |dest_url|, | 498 // PlzNavigate |
481 // possibly reusing the current SiteInstance. If --process-per-tab is used, | 499 // Returns true if |candidate_instance| is a valid SiteInstance for a |
482 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns | 500 // navigation to |dest_url| given all the provided context. |
483 // true. |source_instance| is the SiteInstance of the frame that initiated the | 501 bool IsCorrectSiteInstanceForURL(SiteInstance* candidate_instance, |
484 // navigation. |current_instance| is the SiteInstance of the frame that is | 502 const GURL& dest_url, |
485 // currently navigating. |dest_instance|, is a predetermined SiteInstance | 503 SiteInstance* source_instance, |
486 // that'll be used if not null. | 504 SiteInstance* dest_instance, |
505 ui::PageTransition transition, | |
506 bool dest_is_restore, | |
507 bool dest_is_view_source_mode); | |
508 | |
509 // Returns a descriptor of the appropriate SiteInstance object for the given | |
510 // |dest_url|, possibly reusing the current, source or destination | |
511 // SiteInstance. It will check ShouldTransitionCrossSite and | |
512 // ShouldSwapBrowsingInstancesForNavigation. | |
513 // |source_instance| is the SiteInstance of the frame that initiated the | |
514 // navigation. |dest_instance|, is a predetermined SiteInstance | |
515 // that'll be used if not null. Internally, |current_instance| is the | |
516 // SiteInstance of the frame that is currently navigating. | |
487 // For example, if you have a parent frame A, which has a child frame B, and | 517 // For example, if you have a parent frame A, which has a child frame B, and |
488 // A is trying to change the src attribute of B, this will cause a navigation | 518 // A is trying to change the src attribute of B, this will cause a navigation |
489 // where the source SiteInstance is A and B is the current SiteInstance. | 519 // where the source SiteInstance is A and B is the current SiteInstance. |
490 // This is a helper function for GetSiteInstanceForNavigation. | 520 // This is a helper function for GetSiteInstanceForNavigation and |
491 SiteInstance* GetSiteInstanceForURL(const GURL& dest_url, | 521 // IsCorrectSiteInstanceForURL. |
492 SiteInstance* source_instance, | 522 SiteInstanceDescriptor DetermineSiteInstanceForURL( |
493 SiteInstance* current_instance, | 523 const GURL& dest_url, |
494 SiteInstance* dest_instance, | 524 SiteInstance* source_instance, |
495 ui::PageTransition transition, | 525 SiteInstance* dest_instance, |
496 bool dest_is_restore, | 526 ui::PageTransition transition, |
497 bool dest_is_view_source_mode, | 527 bool dest_is_restore, |
498 bool force_browsing_instance_swap); | 528 bool dest_is_view_source_mode); |
529 SiteInstanceDescriptor DetermineSiteInstanceForURLInternal( | |
clamy
2015/03/23 15:26:44
Why do we have a DetermineSiteInstanceForURL and a
carlosk
2015/03/23 17:39:19
I guess you are asking about the DetermineSiteInst
| |
530 const GURL& dest_url, | |
531 SiteInstance* source_instance, | |
532 SiteInstance* current_instance, | |
533 SiteInstance* dest_instance, | |
534 ui::PageTransition transition, | |
535 bool dest_is_restore, | |
536 bool dest_is_view_source_mode, | |
537 bool force_browsing_instance_swap); | |
carlosk
2015/03/23 14:31:18
I adapted this comment above so that it now fits w
| |
499 | 538 |
500 // Determines the appropriate url to use as the current url for SiteInstance | 539 // Determines the appropriate url to use as the current url for SiteInstance |
501 // selection. | 540 // selection. |
502 const GURL& GetCurrentURLForSiteInstance( | 541 const GURL& GetCurrentURLForSiteInstance( |
503 SiteInstance* current_instance, | 542 SiteInstance* current_instance, |
504 NavigationEntry* current_entry); | 543 NavigationEntry* current_entry); |
505 | 544 |
506 // Creates a new RenderFrameHostImpl for the |new_instance| and assign it to | 545 // Creates a new RenderFrameHostImpl for the |new_instance| and assign it to |
507 // |pending_render_frame_host_| while respecting the opener route if needed | 546 // |pending_render_frame_host_| while respecting the opener route if needed |
508 // and stores it in pending_render_frame_host_. | 547 // and stores it in pending_render_frame_host_. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 bool should_reuse_web_ui_; | 744 bool should_reuse_web_ui_; |
706 | 745 |
707 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 746 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
708 | 747 |
709 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 748 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
710 }; | 749 }; |
711 | 750 |
712 } // namespace content | 751 } // namespace content |
713 | 752 |
714 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 753 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |