Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.h

Issue 967383002: PlzNavigate: Avoid duplicate SiteInstance creation during navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + content-exporting SiteInstanceDescriptor. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 SiteInstance* instance); 422 SiteInstance* instance);
423 423
424 private: 424 private:
425 friend class NavigatorTestWithBrowserSideNavigation; 425 friend class NavigatorTestWithBrowserSideNavigation;
426 friend class RenderFrameHostManagerTest; 426 friend class RenderFrameHostManagerTest;
427 friend class TestWebContents; 427 friend class TestWebContents;
428 428
429 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, 429 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest,
430 CreateCrossProcessSubframeProxies); 430 CreateCrossProcessSubframeProxies);
431 431
432 // Stores information regarding a SiteInstance targeted at a specific URL to
433 // allow for comparisons without having to actually create new instances. It
434 // can point to an existing one or store the details needed to create a new
435 // one.
436 struct CONTENT_EXPORT SiteInstanceDescriptor {
437 explicit SiteInstanceDescriptor(content::SiteInstance* site_instance)
438 : existing_site_instance(site_instance),
439 new_is_related_to_current(false) {}
440
441 SiteInstanceDescriptor(BrowserContext* browser_context,
442 GURL dest_url,
443 bool related_to_current);
444
445 // Set with an existing SiteInstance to be reused.
446 content::SiteInstance* existing_site_instance;
447
448 // In case |existing_site_instance| is null, specify a new site URL.
449 GURL new_site_url;
450
451 // In case |existing_site_instance| is null, specify if the new site should
452 // be created in a new BrowsingInstance or not.
453 bool new_is_related_to_current;
454 };
455
432 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a 456 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a
433 // FrameTreeNode's RenderFrameHostManager. 457 // FrameTreeNode's RenderFrameHostManager.
434 static bool ClearProxiesInSiteInstance(int32 site_instance_id, 458 static bool ClearProxiesInSiteInstance(int32 site_instance_id,
435 FrameTreeNode* node); 459 FrameTreeNode* node);
436 // Used with FrameTree::ForEach to reset initialized state of 460 // Used with FrameTree::ForEach to reset initialized state of
437 // RenderFrameProxyHosts from a FrameTreeNode's RenderFrameHostManager. 461 // RenderFrameProxyHosts from a FrameTreeNode's RenderFrameHostManager.
438 static bool ResetProxiesInSiteInstance(int32 site_instance_id, 462 static bool ResetProxiesInSiteInstance(int32 site_instance_id,
439 FrameTreeNode* node); 463 FrameTreeNode* node);
440 464
441 // Returns whether this tab should transition to a new renderer for 465 // Returns whether this tab should transition to a new renderer for
(...skipping 28 matching lines...) Expand all
470 // Returns true if it is safe to reuse the current WebUI when navigating from 494 // Returns true if it is safe to reuse the current WebUI when navigating from
471 // |current_entry| to |new_url|. 495 // |current_entry| to |new_url|.
472 bool ShouldReuseWebUI( 496 bool ShouldReuseWebUI(
473 const NavigationEntry* current_entry, 497 const NavigationEntry* current_entry,
474 const GURL& new_url) const; 498 const GURL& new_url) const;
475 499
476 // Returns the SiteInstance to use for the navigation. 500 // Returns the SiteInstance to use for the navigation.
477 SiteInstance* GetSiteInstanceForNavigation(const GURL& dest_url, 501 SiteInstance* GetSiteInstanceForNavigation(const GURL& dest_url,
478 SiteInstance* source_instance, 502 SiteInstance* source_instance,
479 SiteInstance* dest_instance, 503 SiteInstance* dest_instance,
504 SiteInstance* candidate_instance,
480 ui::PageTransition transition, 505 ui::PageTransition transition,
481 bool dest_is_restore, 506 bool dest_is_restore,
482 bool dest_is_view_source_mode); 507 bool dest_is_view_source_mode);
483 508
484 // Returns an appropriate SiteInstance object for the given |dest_url|, 509 // Returns a descriptor of the appropriate SiteInstance object for the given
485 // possibly reusing the current SiteInstance. If --process-per-tab is used, 510 // |dest_url|, possibly reusing the current, source or destination
486 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns 511 // SiteInstance. The actual SiteInstance can then be obtained calling
487 // true. |source_instance| is the SiteInstance of the frame that initiated the 512 // ConvertToSiteInstance with the descriptor.
513 //
514 // |source_instance| is the SiteInstance of the frame that initiated the
488 // navigation. |current_instance| is the SiteInstance of the frame that is 515 // navigation. |current_instance| is the SiteInstance of the frame that is
489 // currently navigating. |dest_instance|, is a predetermined SiteInstance 516 // currently navigating. |dest_instance| is a predetermined SiteInstance that
490 // that'll be used if not null. 517 // will be used if not null.
491 // For example, if you have a parent frame A, which has a child frame B, and 518 // For example, if you have a parent frame A, which has a child frame B, and
492 // A is trying to change the src attribute of B, this will cause a navigation 519 // A is trying to change the src attribute of B, this will cause a navigation
493 // where the source SiteInstance is A and B is the current SiteInstance. 520 // where the source SiteInstance is A and B is the current SiteInstance.
521 //
494 // This is a helper function for GetSiteInstanceForNavigation. 522 // This is a helper function for GetSiteInstanceForNavigation.
495 SiteInstance* GetSiteInstanceForURL(const GURL& dest_url, 523 SiteInstanceDescriptor DetermineSiteInstanceForURL(
496 SiteInstance* source_instance, 524 const GURL& dest_url,
497 SiteInstance* current_instance, 525 SiteInstance* source_instance,
498 SiteInstance* dest_instance, 526 SiteInstance* current_instance,
499 ui::PageTransition transition, 527 SiteInstance* dest_instance,
500 bool dest_is_restore, 528 ui::PageTransition transition,
501 bool dest_is_view_source_mode, 529 bool dest_is_restore,
502 bool force_browsing_instance_swap); 530 bool dest_is_view_source_mode,
531 bool force_browsing_instance_swap);
532
533 // Converts a SiteInstanceDescriptor to the actual SiteInstance it describes.
534 // If a |candidate_instance| is provided (is not nullptr) and it matches the
535 // description, it is returned as is.
536 SiteInstance* ConvertToSiteInstance(const SiteInstanceDescriptor& descriptor,
537 SiteInstance* candidate_instance);
503 538
504 // 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
505 // selection. 540 // selection.
506 const GURL& GetCurrentURLForSiteInstance( 541 const GURL& GetCurrentURLForSiteInstance(
507 SiteInstance* current_instance, 542 SiteInstance* current_instance,
508 NavigationEntry* current_entry); 543 NavigationEntry* current_entry);
509 544
510 // 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
511 // |pending_render_frame_host_| while respecting the opener route if needed 546 // |pending_render_frame_host_| while respecting the opener route if needed
512 // and stores it in pending_render_frame_host_. 547 // and stores it in pending_render_frame_host_.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 bool should_reuse_web_ui_; 746 bool should_reuse_web_ui_;
712 747
713 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 748 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
714 749
715 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 750 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
716 }; 751 };
717 752
718 } // namespace content 753 } // namespace content
719 754
720 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 755 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl_unittest.cc ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698