| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 GURL dest_url, | 1022 GURL dest_url, |
| 1023 SiteInstanceRelation relation_to_current) | 1023 SiteInstanceRelation relation_to_current) |
| 1024 : existing_site_instance(nullptr), relation(relation_to_current) { | 1024 : existing_site_instance(nullptr), relation(relation_to_current) { |
| 1025 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url); | 1025 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) { | 1028 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) { |
| 1029 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false); | 1029 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void RenderFrameHostManager::CancelPendingIfNecessary( |
| 1033 RenderFrameHostImpl* render_frame_host) { |
| 1034 if (render_frame_host == pending_render_frame_host_.get()) |
| 1035 CancelPending(); |
| 1036 else if (render_frame_host == speculative_render_frame_host_.get()) { |
| 1037 // TODO(nasko, clamy): This should just clean up the speculative RFH |
| 1038 // without canceling the request. See https://crbug.com/636119. |
| 1039 frame_tree_node_->ResetNavigationRequest(false); |
| 1040 } |
| 1041 } |
| 1042 |
| 1032 void RenderFrameHostManager::ActiveFrameCountIsZero( | 1043 void RenderFrameHostManager::ActiveFrameCountIsZero( |
| 1033 SiteInstanceImpl* site_instance) { | 1044 SiteInstanceImpl* site_instance) { |
| 1034 // |site_instance| no longer contains any active RenderFrameHosts, so we don't | 1045 // |site_instance| no longer contains any active RenderFrameHosts, so we don't |
| 1035 // need to maintain a proxy there anymore. | 1046 // need to maintain a proxy there anymore. |
| 1036 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); | 1047 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); |
| 1037 CHECK(proxy); | 1048 CHECK(proxy); |
| 1038 | 1049 |
| 1039 DeleteRenderFrameProxyHost(site_instance); | 1050 DeleteRenderFrameProxyHost(site_instance); |
| 1040 } | 1051 } |
| 1041 | 1052 |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 delegate_->NotifySwappedFromRenderManager( | 2140 delegate_->NotifySwappedFromRenderManager( |
| 2130 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); | 2141 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); |
| 2131 | 2142 |
| 2132 // The RenderViewHost keeps track of the main RenderFrameHost routing id. | 2143 // The RenderViewHost keeps track of the main RenderFrameHost routing id. |
| 2133 // If this is committing a main frame navigation, update it and set the | 2144 // If this is committing a main frame navigation, update it and set the |
| 2134 // routing id in the RenderViewHost associated with the old RenderFrameHost | 2145 // routing id in the RenderViewHost associated with the old RenderFrameHost |
| 2135 // to MSG_ROUTING_NONE. | 2146 // to MSG_ROUTING_NONE. |
| 2136 if (is_main_frame) { | 2147 if (is_main_frame) { |
| 2137 render_frame_host_->render_view_host()->set_main_frame_routing_id( | 2148 render_frame_host_->render_view_host()->set_main_frame_routing_id( |
| 2138 render_frame_host_->routing_id()); | 2149 render_frame_host_->routing_id()); |
| 2150 render_frame_host_->render_view_host()->set_is_active(true); |
| 2151 render_frame_host_->render_view_host()->set_is_swapped_out(false); |
| 2139 old_render_frame_host->render_view_host()->set_main_frame_routing_id( | 2152 old_render_frame_host->render_view_host()->set_main_frame_routing_id( |
| 2140 MSG_ROUTING_NONE); | 2153 MSG_ROUTING_NONE); |
| 2141 } | 2154 } |
| 2142 | 2155 |
| 2143 // Swap out the old frame now that the new one is visible. | 2156 // Swap out the old frame now that the new one is visible. |
| 2144 // This will swap it out and schedule it for deletion when the swap out ack | 2157 // This will swap it out and schedule it for deletion when the swap out ack |
| 2145 // arrives (or immediately if the process isn't live). | 2158 // arrives (or immediately if the process isn't live). |
| 2146 SwapOutOldFrame(std::move(old_render_frame_host)); | 2159 SwapOutOldFrame(std::move(old_render_frame_host)); |
| 2147 | 2160 |
| 2148 // Since the new RenderFrameHost is now committed, there must be no proxies | 2161 // Since the new RenderFrameHost is now committed, there must be no proxies |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 | 2199 |
| 2187 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2200 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 2188 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2201 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
| 2189 dest_url, source_instance, dest_instance, nullptr, transition, | 2202 dest_url, source_instance, dest_instance, nullptr, transition, |
| 2190 dest_is_restore, dest_is_view_source_mode); | 2203 dest_is_restore, dest_is_view_source_mode); |
| 2191 | 2204 |
| 2192 // If we are currently navigating cross-process to a pending RFH for a | 2205 // If we are currently navigating cross-process to a pending RFH for a |
| 2193 // different SiteInstance, we want to get back to normal and then navigate as | 2206 // different SiteInstance, we want to get back to normal and then navigate as |
| 2194 // usual. We will reuse the pending RFH below if it matches the destination | 2207 // usual. We will reuse the pending RFH below if it matches the destination |
| 2195 // SiteInstance. | 2208 // SiteInstance. |
| 2196 if (pending_render_frame_host_ && | 2209 if (pending_render_frame_host_) { |
| 2197 pending_render_frame_host_->GetSiteInstance() != new_instance) | 2210 if (pending_render_frame_host_->GetSiteInstance() != new_instance) { |
| 2198 CancelPending(); | 2211 CancelPending(); |
| 2212 } else { |
| 2213 // When a pending RFH is reused, it should always be live, since it is |
| 2214 // cleared whenever a process dies. |
| 2215 CHECK(pending_render_frame_host_->IsRenderFrameLive()); |
| 2216 } |
| 2217 } |
| 2199 | 2218 |
| 2200 if (new_instance.get() != current_instance) { | 2219 if (new_instance.get() != current_instance) { |
| 2201 TRACE_EVENT_INSTANT2( | 2220 TRACE_EVENT_INSTANT2( |
| 2202 "navigation", | 2221 "navigation", |
| 2203 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", | 2222 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", |
| 2204 TRACE_EVENT_SCOPE_THREAD, | 2223 TRACE_EVENT_SCOPE_THREAD, |
| 2205 "current_instance id", current_instance->GetId(), | 2224 "current_instance id", current_instance->GetId(), |
| 2206 "new_instance id", new_instance->GetId()); | 2225 "new_instance id", new_instance->GetId()); |
| 2207 | 2226 |
| 2208 // New SiteInstance: create a pending RFH to navigate. | 2227 // New SiteInstance: create a pending RFH to navigate. |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 resolved_url)) { | 2624 resolved_url)) { |
| 2606 DCHECK(!dest_instance || | 2625 DCHECK(!dest_instance || |
| 2607 dest_instance == render_frame_host_->GetSiteInstance()); | 2626 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2608 return false; | 2627 return false; |
| 2609 } | 2628 } |
| 2610 | 2629 |
| 2611 return true; | 2630 return true; |
| 2612 } | 2631 } |
| 2613 | 2632 |
| 2614 } // namespace content | 2633 } // namespace content |
| OLD | NEW |