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 #include "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 RenderWidgetHostDelegate* render_widget_delegate, | 56 RenderWidgetHostDelegate* render_widget_delegate, |
| 57 Delegate* delegate) | 57 Delegate* delegate) |
| 58 : frame_tree_node_(frame_tree_node), | 58 : frame_tree_node_(frame_tree_node), |
| 59 delegate_(delegate), | 59 delegate_(delegate), |
| 60 cross_navigation_pending_(false), | 60 cross_navigation_pending_(false), |
| 61 render_frame_delegate_(render_frame_delegate), | 61 render_frame_delegate_(render_frame_delegate), |
| 62 render_view_delegate_(render_view_delegate), | 62 render_view_delegate_(render_view_delegate), |
| 63 render_widget_delegate_(render_widget_delegate), | 63 render_widget_delegate_(render_widget_delegate), |
| 64 interstitial_page_(nullptr), | 64 interstitial_page_(nullptr), |
| 65 should_reuse_web_ui_(false), | 65 should_reuse_web_ui_(false), |
| 66 pending_commit_current_frame_(false), | |
| 67 pending_commit_speculative_frame_(false), | |
| 66 weak_factory_(this) { | 68 weak_factory_(this) { |
| 67 DCHECK(frame_tree_node_); | 69 DCHECK(frame_tree_node_); |
| 68 } | 70 } |
| 69 | 71 |
| 70 RenderFrameHostManager::~RenderFrameHostManager() { | 72 RenderFrameHostManager::~RenderFrameHostManager() { |
| 71 if (pending_render_frame_host_) | 73 if (pending_render_frame_host_) |
| 72 UnsetPendingRenderFrameHost(); | 74 UnsetPendingRenderFrameHost(); |
| 73 | 75 |
| 74 if (speculative_render_frame_host_) | 76 if (speculative_render_frame_host_) |
| 75 UnsetSpeculativeRenderFrameHost(); | 77 UnsetSpeculativeRenderFrameHost(); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 // prior to navigation take effect. | 453 // prior to navigation take effect. |
| 452 CommitPendingSandboxFlags(); | 454 CommitPendingSandboxFlags(); |
| 453 } | 455 } |
| 454 | 456 |
| 455 void RenderFrameHostManager::CommitPendingIfNecessary( | 457 void RenderFrameHostManager::CommitPendingIfNecessary( |
| 456 RenderFrameHostImpl* render_frame_host, | 458 RenderFrameHostImpl* render_frame_host, |
| 457 bool was_caused_by_user_gesture) { | 459 bool was_caused_by_user_gesture) { |
| 458 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 460 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 459 switches::kEnableBrowserSideNavigation)) { | 461 switches::kEnableBrowserSideNavigation)) { |
| 460 if (render_frame_host == speculative_render_frame_host_.get()) { | 462 if (render_frame_host == speculative_render_frame_host_.get()) { |
| 463 DCHECK(pending_commit_speculative_frame_); | |
| 461 CommitPending(); | 464 CommitPending(); |
| 462 } else if (render_frame_host == render_frame_host_.get()) { | 465 } else if (render_frame_host == render_frame_host_.get()) { |
| 463 // TODO(carlosk): this code doesn't properly handle in-page navigation or | 466 // TODO(carlosk): this code doesn't properly handle in-page navigation or |
| 464 // interwoven navigation requests. | 467 // interwoven navigation requests. |
| 468 DCHECK(pending_commit_current_frame_); | |
|
Charlie Reis
2015/04/03 06:02:58
This appears to be the only place that pending_com
clamy
2015/04/07 16:29:21
So I ended up moving the state tracking to RenderF
Charlie Reis
2015/04/07 17:04:47
Hmm, ok. It would be nice to not need this in shi
| |
| 465 DCHECK(!speculative_render_frame_host_); | 469 DCHECK(!speculative_render_frame_host_); |
| 466 } else { | 470 } else { |
| 467 // No one else should be sending us a DidNavigate in this state. | 471 // No one else should be sending us a DidNavigate in this state. |
| 468 DCHECK(false); | 472 DCHECK(false); |
| 469 } | 473 } |
| 474 // The current frame either committed or was swapped out. | |
| 475 pending_commit_current_frame_ = false; | |
|
Charlie Reis
2015/04/03 06:02:58
What if pending_commit_speculative_frame_ was true
| |
| 470 DCHECK(!speculative_render_frame_host_); | 476 DCHECK(!speculative_render_frame_host_); |
| 471 return; | 477 return; |
| 472 } | 478 } |
| 473 | 479 |
| 474 if (!cross_navigation_pending_) { | 480 if (!cross_navigation_pending_) { |
| 475 DCHECK(!pending_render_frame_host_); | 481 DCHECK(!pending_render_frame_host_); |
| 476 | 482 |
| 477 // We should only hear this from our current renderer. | 483 // We should only hear this from our current renderer. |
| 478 DCHECK_EQ(render_frame_host_, render_frame_host); | 484 DCHECK_EQ(render_frame_host_, render_frame_host); |
| 479 | 485 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 | 730 |
| 725 // PlzNavigate | 731 // PlzNavigate |
| 726 void RenderFrameHostManager::BeginNavigation(const NavigationRequest& request) { | 732 void RenderFrameHostManager::BeginNavigation(const NavigationRequest& request) { |
| 727 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 733 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 728 switches::kEnableBrowserSideNavigation)); | 734 switches::kEnableBrowserSideNavigation)); |
| 729 // Clean up any state in case there's an ongoing navigation. | 735 // Clean up any state in case there's an ongoing navigation. |
| 730 // TODO(carlosk): remove this cleanup here once we properly cancel ongoing | 736 // TODO(carlosk): remove this cleanup here once we properly cancel ongoing |
| 731 // navigations. | 737 // navigations. |
| 732 CleanUpNavigation(); | 738 CleanUpNavigation(); |
| 733 | 739 |
| 734 RenderFrameHostImpl* dest_rfh = GetFrameHostForNavigation(request); | 740 RenderFrameHostImpl* dest_rfh = GetFrameHostForNavigation(request, false); |
| 735 DCHECK(dest_rfh); | 741 DCHECK(dest_rfh); |
| 736 } | 742 } |
| 737 | 743 |
| 738 // PlzNavigate | 744 // PlzNavigate |
| 739 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( | 745 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( |
| 740 const NavigationRequest& request) { | 746 const NavigationRequest& request, |
| 747 bool is_for_commit) { | |
| 741 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 748 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 742 switches::kEnableBrowserSideNavigation)); | 749 switches::kEnableBrowserSideNavigation)); |
| 743 | 750 |
| 744 SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); | 751 SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); |
| 745 | 752 |
| 746 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( | 753 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( |
| 747 request.common_params().url, request.source_site_instance(), | 754 request.common_params().url, request.source_site_instance(), |
| 748 request.dest_site_instance(), request.common_params().transition, | 755 request.dest_site_instance(), request.common_params().transition, |
| 749 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 756 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
| 750 request.is_view_source()); | 757 request.is_view_source()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 if (!navigation_rfh->IsRenderFrameLive()) { | 827 if (!navigation_rfh->IsRenderFrameLive()) { |
| 821 // Recreate the opener chain. | 828 // Recreate the opener chain. |
| 822 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( | 829 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( |
| 823 navigation_rfh->GetSiteInstance()); | 830 navigation_rfh->GetSiteInstance()); |
| 824 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id, | 831 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id, |
| 825 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) { | 832 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) { |
| 826 return nullptr; | 833 return nullptr; |
| 827 } | 834 } |
| 828 } | 835 } |
| 829 | 836 |
| 830 cross_navigation_pending_ = navigation_rfh != render_frame_host_.get(); | 837 // Register that a commit is pending. |
| 838 if (is_for_commit) { | |
|
Charlie Reis
2015/04/03 06:02:58
This is only used at the end of the method and doe
| |
| 839 if (navigation_rfh == render_frame_host_.get()) | |
| 840 pending_commit_current_frame_ = true; | |
| 841 else | |
| 842 pending_commit_speculative_frame_ = true; | |
| 843 } | |
| 844 | |
| 831 return navigation_rfh; | 845 return navigation_rfh; |
| 832 } | 846 } |
| 833 | 847 |
| 834 // PlzNavigate | 848 // PlzNavigate |
| 835 void RenderFrameHostManager::CleanUpNavigation() { | 849 void RenderFrameHostManager::CleanUpNavigation() { |
| 836 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 850 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 837 switches::kEnableBrowserSideNavigation)); | 851 switches::kEnableBrowserSideNavigation)); |
| 838 speculative_web_ui_.reset(); | 852 speculative_web_ui_.reset(); |
| 839 should_reuse_web_ui_ = false; | 853 should_reuse_web_ui_ = false; |
| 854 pending_commit_speculative_frame_ = false; | |
|
Charlie Reis
2015/04/03 06:02:59
This is where your comment about it being impossib
| |
| 840 if (speculative_render_frame_host_) | 855 if (speculative_render_frame_host_) |
| 841 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | 856 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
| 842 } | 857 } |
| 843 | 858 |
| 844 // PlzNavigate | 859 // PlzNavigate |
| 845 scoped_ptr<RenderFrameHostImpl> | 860 scoped_ptr<RenderFrameHostImpl> |
| 846 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { | 861 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { |
| 847 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 862 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 848 switches::kEnableBrowserSideNavigation)); | 863 switches::kEnableBrowserSideNavigation)); |
| 849 speculative_render_frame_host_->GetProcess()->RemovePendingView(); | 864 speculative_render_frame_host_->GetProcess()->RemovePendingView(); |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1664 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; | 1679 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; |
| 1665 if (!browser_side_navigation) { | 1680 if (!browser_side_navigation) { |
| 1666 DCHECK(!speculative_render_frame_host_); | 1681 DCHECK(!speculative_render_frame_host_); |
| 1667 old_render_frame_host = | 1682 old_render_frame_host = |
| 1668 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 1683 SetRenderFrameHost(pending_render_frame_host_.Pass()); |
| 1669 } else { | 1684 } else { |
| 1670 // PlzNavigate | 1685 // PlzNavigate |
| 1671 DCHECK(speculative_render_frame_host_); | 1686 DCHECK(speculative_render_frame_host_); |
| 1672 old_render_frame_host = | 1687 old_render_frame_host = |
| 1673 SetRenderFrameHost(speculative_render_frame_host_.Pass()); | 1688 SetRenderFrameHost(speculative_render_frame_host_.Pass()); |
| 1689 pending_commit_speculative_frame_ = false; | |
| 1674 } | 1690 } |
| 1675 cross_navigation_pending_ = false; | 1691 cross_navigation_pending_ = false; |
| 1676 | 1692 |
| 1677 if (is_main_frame) | 1693 if (is_main_frame) |
| 1678 render_frame_host_->render_view_host()->AttachToFrameTree(); | 1694 render_frame_host_->render_view_host()->AttachToFrameTree(); |
| 1679 | 1695 |
| 1680 // The process will no longer try to exit, so we can decrement the count. | 1696 // The process will no longer try to exit, so we can decrement the count. |
| 1681 render_frame_host_->GetProcess()->RemovePendingView(); | 1697 render_frame_host_->GetProcess()->RemovePendingView(); |
| 1682 | 1698 |
| 1683 // Show the new view (or a sad tab) if necessary. | 1699 // Show the new view (or a sad tab) if necessary. |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2019 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2035 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 2020 SiteInstance* instance) { | 2036 SiteInstance* instance) { |
| 2021 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2037 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 2022 if (iter != proxy_hosts_.end()) { | 2038 if (iter != proxy_hosts_.end()) { |
| 2023 delete iter->second; | 2039 delete iter->second; |
| 2024 proxy_hosts_.erase(iter); | 2040 proxy_hosts_.erase(iter); |
| 2025 } | 2041 } |
| 2026 } | 2042 } |
| 2027 | 2043 |
| 2028 } // namespace content | 2044 } // namespace content |
| OLD | NEW |