| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (current_site_instance == dest_site_instance.get() || | 687 if (current_site_instance == dest_site_instance.get() || |
| 688 (!frame_tree_node_->IsMainFrame() && | 688 (!frame_tree_node_->IsMainFrame() && |
| 689 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 689 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 690 switches::kSitePerProcess))) { | 690 switches::kSitePerProcess))) { |
| 691 // Reuse the current RFH if its SiteInstance matches the the navigation's | 691 // Reuse the current RFH if its SiteInstance matches the the navigation's |
| 692 // or if this is a subframe navigation. We only swap RFHs for subframes when | 692 // or if this is a subframe navigation. We only swap RFHs for subframes when |
| 693 // --site-per-process is enabled. | 693 // --site-per-process is enabled. |
| 694 CleanUpNavigation(); | 694 CleanUpNavigation(); |
| 695 navigation_rfh = render_frame_host_.get(); | 695 navigation_rfh = render_frame_host_.get(); |
| 696 } else { | 696 } else { |
| 697 // If the current render_frame_host_ isn't live, we should create it so | |
| 698 // that we don't show a sad tab while the navigation is ongoing. | |
| 699 // (Bug 1145340) | |
| 700 if (!render_frame_host_->IsRenderFrameLive()) { | |
| 701 // Note: we don't call InitRenderView here because we are navigating away | |
| 702 // soon anyway, and we don't have the NavigationEntry for this host. | |
| 703 delegate_->CreateRenderViewForRenderManager( | |
| 704 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, | |
| 705 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame()); | |
| 706 } | |
| 707 | |
| 708 // If the SiteInstance for the final URL doesn't match the one from the | 697 // If the SiteInstance for the final URL doesn't match the one from the |
| 709 // speculatively created RenderFrameHost, create a new RenderFrameHost using | 698 // speculatively created RenderFrameHost, create a new RenderFrameHost using |
| 710 // this new SiteInstance. | 699 // this new SiteInstance. |
| 711 if (!speculative_render_frame_host_ || | 700 if (!speculative_render_frame_host_ || |
| 712 speculative_render_frame_host_->GetSiteInstance() != | 701 speculative_render_frame_host_->GetSiteInstance() != |
| 713 dest_site_instance.get()) { | 702 dest_site_instance.get()) { |
| 714 CleanUpNavigation(); | 703 CleanUpNavigation(); |
| 715 bool success = CreateSpeculativeRenderFrameHost( | 704 bool success = CreateSpeculativeRenderFrameHost( |
| 716 request.common_params().url, current_site_instance, | 705 request.common_params().url, current_site_instance, |
| 717 dest_site_instance.get(), request.bindings()); | 706 dest_site_instance.get(), request.bindings()); |
| 718 DCHECK(success); | 707 DCHECK(success); |
| 719 } | 708 } |
| 720 DCHECK(speculative_render_frame_host_); | 709 DCHECK(speculative_render_frame_host_); |
| 721 navigation_rfh = speculative_render_frame_host_.get(); | 710 navigation_rfh = speculative_render_frame_host_.get(); |
| 711 |
| 712 // Check if our current RFH is live. |
| 713 if (!render_frame_host_->IsRenderFrameLive()) { |
| 714 // The current RFH is not live. There's no reason to sit around with a |
| 715 // sad tab or a newly created RFH while we wait for the navigation to |
| 716 // complete. Just switch to the speculative RFH now and go back to non |
| 717 // cross-navigating (Note that we don't care about on{before}unload |
| 718 // handlers if the current RFH isn't live.) |
| 719 CommitPending(); |
| 720 } |
| 722 } | 721 } |
| 723 DCHECK(navigation_rfh && | 722 DCHECK(navigation_rfh && |
| 724 (navigation_rfh == render_frame_host_.get() || | 723 (navigation_rfh == render_frame_host_.get() || |
| 725 navigation_rfh == speculative_render_frame_host_.get())); | 724 navigation_rfh == speculative_render_frame_host_.get())); |
| 726 | 725 |
| 727 // If the RenderFrame that needs to navigate is not live (its process was just | 726 // If the RenderFrame that needs to navigate is not live (its process was just |
| 728 // created or has crashed), initialize it. | 727 // created or has crashed), initialize it. |
| 729 if (!navigation_rfh->IsRenderFrameLive()) { | 728 if (!navigation_rfh->IsRenderFrameLive()) { |
| 730 // Recreate the opener chain. | 729 // Recreate the opener chain. |
| 731 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( | 730 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1881 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1883 SiteInstance* instance) { | 1882 SiteInstance* instance) { |
| 1884 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1883 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 1885 if (iter != proxy_hosts_.end()) { | 1884 if (iter != proxy_hosts_.end()) { |
| 1886 delete iter->second; | 1885 delete iter->second; |
| 1887 proxy_hosts_.erase(iter); | 1886 proxy_hosts_.erase(iter); |
| 1888 } | 1887 } |
| 1889 } | 1888 } |
| 1890 | 1889 |
| 1891 } // namespace content | 1890 } // namespace content |
| OLD | NEW |