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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 return NULL; // We weren't able to create a pending render frame host. | 168 return NULL; // We weren't able to create a pending render frame host. |
169 | 169 |
170 // If the current render_frame_host_ isn't live, we should create it so | 170 // If the current render_frame_host_ isn't live, we should create it so |
171 // that we don't show a sad tab while the dest_render_frame_host fetches | 171 // that we don't show a sad tab while the dest_render_frame_host fetches |
172 // its first page. (Bug 1145340) | 172 // its first page. (Bug 1145340) |
173 if (dest_render_frame_host != render_frame_host_ && | 173 if (dest_render_frame_host != render_frame_host_ && |
174 !render_frame_host_->render_view_host()->IsRenderViewLive()) { | 174 !render_frame_host_->render_view_host()->IsRenderViewLive()) { |
175 // Note: we don't call InitRenderView here because we are navigating away | 175 // Note: we don't call InitRenderView here because we are navigating away |
176 // soon anyway, and we don't have the NavigationEntry for this host. | 176 // soon anyway, and we don't have the NavigationEntry for this host. |
177 delegate_->CreateRenderViewForRenderManager( | 177 delegate_->CreateRenderViewForRenderManager( |
178 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, NULL); | 178 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, |
179 MSG_ROUTING_NONE, NULL); | |
179 } | 180 } |
180 | 181 |
181 // If the renderer crashed, then try to create a new one to satisfy this | 182 // If the renderer crashed, then try to create a new one to satisfy this |
182 // navigation request. | 183 // navigation request. |
183 if (!dest_render_frame_host->render_view_host()->IsRenderViewLive()) { | 184 if (!dest_render_frame_host->render_view_host()->IsRenderViewLive()) { |
184 // Recreate the opener chain. | 185 // Recreate the opener chain. |
185 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( | 186 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( |
186 dest_render_frame_host->GetSiteInstance()); | 187 dest_render_frame_host->GetSiteInstance()); |
187 if (!InitRenderView(dest_render_frame_host->render_view_host(), | 188 if (!InitRenderView(dest_render_frame_host->render_view_host(), |
188 opener_route_id)) | 189 opener_route_id, MSG_ROUTING_NONE)) |
189 return NULL; | 190 return NULL; |
190 | 191 |
191 // Now that we've created a new renderer, be sure to hide it if it isn't | 192 // Now that we've created a new renderer, be sure to hide it if it isn't |
192 // our primary one. Otherwise, we might crash if we try to call Show() | 193 // our primary one. Otherwise, we might crash if we try to call Show() |
193 // on it later. | 194 // on it later. |
194 if (dest_render_frame_host != render_frame_host_ && | 195 if (dest_render_frame_host != render_frame_host_ && |
195 dest_render_frame_host->render_view_host()->GetView()) { | 196 dest_render_frame_host->render_view_host()->GetView()) { |
196 dest_render_frame_host->render_view_host()->GetView()->Hide(); | 197 dest_render_frame_host->render_view_host()->GetView()->Hide(); |
197 } else if (frame_tree_node_->IsMainFrame()) { | 198 } else if (frame_tree_node_->IsMainFrame()) { |
198 // This is our primary renderer, notify here as we won't be calling | 199 // This is our primary renderer, notify here as we won't be calling |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 // The same CrossProcessFrameConnector is used for subsequent cross- | 500 // The same CrossProcessFrameConnector is used for subsequent cross- |
500 // process navigations, but it will be destroyed if the Frame is | 501 // process navigations, but it will be destroyed if the Frame is |
501 // navigated back to the same site instance as its parent. | 502 // navigated back to the same site instance as its parent. |
502 // TODO(kenrb): This will change when RenderFrameProxyHost is created. | 503 // TODO(kenrb): This will change when RenderFrameProxyHost is created. |
503 if (!cross_process_frame_connector_) { | 504 if (!cross_process_frame_connector_) { |
504 cross_process_frame_connector_ = | 505 cross_process_frame_connector_ = |
505 new CrossProcessFrameConnector(render_frame_host_.get()); | 506 new CrossProcessFrameConnector(render_frame_host_.get()); |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
510 // Create the RenderFrameProxyHost that will replace the | |
511 // RenderFrameHost which is swapping out. If one exists, ensure it is deleted | |
512 // from the map and not leaked. | |
513 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( | |
514 render_frame_host_->GetSiteInstance()->GetId()); | |
515 if (iter != proxy_hosts_.end()) { | |
516 delete iter->second; | |
517 proxy_hosts_.erase(iter); | |
518 } | |
519 | |
520 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | |
521 render_frame_host_->GetSiteInstance(), frame_tree_node_); | |
Charlie Reis
2014/05/15 22:55:00
nit: Wrong indent.
nasko
2014/05/15 23:36:49
Done.
| |
522 proxy_hosts_[render_frame_host_->GetSiteInstance()->GetId()] = proxy; | |
523 | |
509 // Tell the old frame it is being swapped out. This will fire the unload | 524 // Tell the old frame it is being swapped out. This will fire the unload |
510 // handler in the background (without firing the beforeunload handler a second | 525 // handler in the background (without firing the beforeunload handler a second |
511 // time). When the navigation completes, we will send a message to the | 526 // time). When the navigation completes, we will send a message to the |
512 // ResourceDispatcherHost, allowing the pending RVH's response to resume. | 527 // ResourceDispatcherHost, allowing the pending RVH's response to resume. |
513 render_frame_host_->SwapOut(); | 528 render_frame_host_->SwapOut(proxy); |
514 | 529 |
515 // ResourceDispatcherHost has told us to run the onunload handler, which | 530 // ResourceDispatcherHost has told us to run the onunload handler, which |
516 // means it is not a download or unsafe page, and we are going to perform the | 531 // means it is not a download or unsafe page, and we are going to perform the |
517 // navigation. Thus, we no longer need to remember that the RenderFrameHost | 532 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
518 // is part of a pending cross-site request. | 533 // is part of a pending cross-site request. |
519 if (pending_render_frame_host_) { | 534 if (pending_render_frame_host_) { |
520 pending_render_frame_host_->render_view_host()-> | 535 pending_render_frame_host_->render_view_host()-> |
521 SetHasPendingCrossSiteRequest(false); | 536 SetHasPendingCrossSiteRequest(false); |
522 } | 537 } |
523 } | 538 } |
(...skipping 27 matching lines...) Expand all Loading... | |
551 int32 site_instance_id, | 566 int32 site_instance_id, |
552 FrameTreeNode* node) { | 567 FrameTreeNode* node) { |
553 RenderFrameProxyHostMap::iterator iter = | 568 RenderFrameProxyHostMap::iterator iter = |
554 node->render_manager()->proxy_hosts_.find(site_instance_id); | 569 node->render_manager()->proxy_hosts_.find(site_instance_id); |
555 if (iter != node->render_manager()->proxy_hosts_.end()) { | 570 if (iter != node->render_manager()->proxy_hosts_.end()) { |
556 RenderFrameProxyHost* proxy = iter->second; | 571 RenderFrameProxyHost* proxy = iter->second; |
557 // If the RVH is pending swap out, it needs to switch state to | 572 // If the RVH is pending swap out, it needs to switch state to |
558 // pending shutdown. Otherwise it is deleted. | 573 // pending shutdown. Otherwise it is deleted. |
559 if (proxy->render_view_host()->rvh_state() == | 574 if (proxy->render_view_host()->rvh_state() == |
560 RenderViewHostImpl::STATE_PENDING_SWAP_OUT) { | 575 RenderViewHostImpl::STATE_PENDING_SWAP_OUT) { |
561 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh = proxy->PassFrameHost(); | 576 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh = |
577 proxy->PassFrameHostOwnership(); | |
562 | 578 |
563 swapped_out_rfh->SetPendingShutdown(base::Bind( | 579 swapped_out_rfh->SetPendingShutdown(base::Bind( |
564 &RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance, | 580 &RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance, |
565 node->render_manager()->weak_factory_.GetWeakPtr(), | 581 node->render_manager()->weak_factory_.GetWeakPtr(), |
566 site_instance_id, | 582 site_instance_id, |
567 swapped_out_rfh.get())); | 583 swapped_out_rfh.get())); |
568 RFHPendingDeleteMap::iterator pending_delete_iter = | 584 RFHPendingDeleteMap::iterator pending_delete_iter = |
569 node->render_manager()->pending_delete_hosts_.find(site_instance_id); | 585 node->render_manager()->pending_delete_hosts_.find(site_instance_id); |
570 if (pending_delete_iter == | 586 if (pending_delete_iter == |
571 node->render_manager()->pending_delete_hosts_.end() || | 587 node->render_manager()->pending_delete_hosts_.end() || |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
894 // remove it from the list of swapped out hosts if it commits. | 910 // remove it from the list of swapped out hosts if it commits. |
895 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 911 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
896 | 912 |
897 FrameTreeNode* parent_node = frame_tree_node_->parent(); | 913 FrameTreeNode* parent_node = frame_tree_node_->parent(); |
898 | 914 |
899 if (proxy) { | 915 if (proxy) { |
900 routing_id = proxy->render_view_host()->GetRoutingID(); | 916 routing_id = proxy->render_view_host()->GetRoutingID(); |
901 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 917 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
902 // Prevent the process from exiting while we're trying to use it. | 918 // Prevent the process from exiting while we're trying to use it. |
903 if (!swapped_out) { | 919 if (!swapped_out) { |
904 new_render_frame_host = proxy->PassFrameHost(); | 920 new_render_frame_host = proxy->PassFrameHostOwnership(); |
905 new_render_frame_host->GetProcess()->AddPendingView(); | 921 new_render_frame_host->GetProcess()->AddPendingView(); |
906 | 922 |
907 proxy_hosts_.erase(instance->GetId()); | 923 proxy_hosts_.erase(instance->GetId()); |
908 delete proxy; | 924 delete proxy; |
909 } else { | 925 } else { |
910 // Detect if this is a cross-process child frame that is navigating | 926 // Detect if this is a cross-process child frame that is navigating |
911 // back to the same SiteInstance as its parent. | 927 // back to the same SiteInstance as its parent. |
912 if (parent_node && cross_process_frame_connector_ && | 928 if (parent_node && cross_process_frame_connector_ && |
913 render_frame_host_->GetSiteInstance() == parent_node-> | 929 render_frame_host_->GetSiteInstance() == parent_node-> |
914 render_manager()->current_frame_host()->GetSiteInstance()) { | 930 render_manager()->current_frame_host()->GetSiteInstance()) { |
915 delete cross_process_frame_connector_; | 931 delete cross_process_frame_connector_; |
916 cross_process_frame_connector_ = NULL; | 932 cross_process_frame_connector_ = NULL; |
917 } | 933 } |
918 } | 934 } |
919 } else { | 935 } else { |
920 // Create a new RenderFrameHost if we don't find an existing one. | 936 // Create a new RenderFrameHost if we don't find an existing one. |
921 new_render_frame_host = CreateRenderFrameHost( | 937 new_render_frame_host = CreateRenderFrameHost( |
922 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); | 938 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); |
923 RenderViewHostImpl* render_view_host = | 939 RenderViewHostImpl* render_view_host = |
924 new_render_frame_host->render_view_host(); | 940 new_render_frame_host->render_view_host(); |
941 int proxy_routing_id = MSG_ROUTING_NONE; | |
925 | 942 |
926 // Prevent the process from exiting while we're trying to navigate in it. | 943 // Prevent the process from exiting while we're trying to navigate in it. |
927 // Otherwise, if the new RFH is swapped out already, store it. | 944 // Otherwise, if the new RFH is swapped out already, store it. |
928 if (!swapped_out) { | 945 if (!swapped_out) { |
929 new_render_frame_host->GetProcess()->AddPendingView(); | 946 new_render_frame_host->GetProcess()->AddPendingView(); |
930 } else { | 947 } else { |
931 proxy_hosts_[instance->GetId()] = new RenderFrameProxyHost( | 948 proxy = new RenderFrameProxyHost( |
932 new_render_frame_host.Pass()); | 949 new_render_frame_host->GetSiteInstance(), frame_tree_node_); |
950 proxy_hosts_[instance->GetId()] = proxy; | |
951 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | |
952 proxy_routing_id = proxy->GetRoutingID(); | |
933 } | 953 } |
934 | 954 |
935 bool success = InitRenderView(render_view_host, opener_route_id); | 955 bool success = InitRenderView( |
956 render_view_host, opener_route_id, proxy_routing_id); | |
936 if (success && frame_tree_node_->IsMainFrame()) { | 957 if (success && frame_tree_node_->IsMainFrame()) { |
937 // Don't show the main frame's view until we get a DidNavigate from it. | 958 // Don't show the main frame's view until we get a DidNavigate from it. |
938 render_view_host->GetView()->Hide(); | 959 render_view_host->GetView()->Hide(); |
939 } else if (!swapped_out && pending_render_frame_host_) { | 960 } else if (!swapped_out && pending_render_frame_host_) { |
940 CancelPending(); | 961 CancelPending(); |
941 } | 962 } |
942 routing_id = render_view_host->GetRoutingID(); | 963 routing_id = render_view_host->GetRoutingID(); |
943 } | 964 } |
944 | 965 |
945 // Use this as our new pending RFH if it isn't swapped out. | 966 // Use this as our new pending RFH if it isn't swapped out. |
946 if (!swapped_out) | 967 if (!swapped_out) |
947 pending_render_frame_host_ = new_render_frame_host.Pass(); | 968 pending_render_frame_host_ = new_render_frame_host.Pass(); |
948 | 969 |
949 return routing_id; | 970 return routing_id; |
950 } | 971 } |
951 | 972 |
952 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, | 973 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, |
953 int opener_route_id) { | 974 int opener_route_id, |
975 int proxy_routing_id) { | |
954 // We may have initialized this RenderViewHost for another RenderFrameHost. | 976 // We may have initialized this RenderViewHost for another RenderFrameHost. |
955 if (render_view_host->IsRenderViewLive()) | 977 if (render_view_host->IsRenderViewLive()) |
956 return true; | 978 return true; |
957 | 979 |
958 // If the pending navigation is to a WebUI and the RenderView is not in a | 980 // If the pending navigation is to a WebUI and the RenderView is not in a |
959 // guest process, tell the RenderViewHost about any bindings it will need | 981 // guest process, tell the RenderViewHost about any bindings it will need |
960 // enabled. | 982 // enabled. |
961 if (pending_web_ui() && !render_view_host->GetProcess()->IsGuest()) { | 983 if (pending_web_ui() && !render_view_host->GetProcess()->IsGuest()) { |
962 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); | 984 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); |
963 } else { | 985 } else { |
964 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled | 986 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled |
965 // process unless it's swapped out. | 987 // process unless it's swapped out. |
966 RenderViewHostImpl* rvh_impl = | 988 RenderViewHostImpl* rvh_impl = |
967 static_cast<RenderViewHostImpl*>(render_view_host); | 989 static_cast<RenderViewHostImpl*>(render_view_host); |
968 if (!rvh_impl->IsSwappedOut()) { | 990 if (!rvh_impl->IsSwappedOut()) { |
969 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 991 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
970 render_view_host->GetProcess()->GetID())); | 992 render_view_host->GetProcess()->GetID())); |
971 } | 993 } |
972 } | 994 } |
973 | 995 |
974 return delegate_->CreateRenderViewForRenderManager( | 996 return delegate_->CreateRenderViewForRenderManager( |
975 render_view_host, opener_route_id, cross_process_frame_connector_); | 997 render_view_host, opener_route_id, proxy_routing_id, |
998 cross_process_frame_connector_); | |
976 } | 999 } |
977 | 1000 |
978 void RenderFrameHostManager::CommitPending() { | 1001 void RenderFrameHostManager::CommitPending() { |
979 // First check whether we're going to want to focus the location bar after | 1002 // First check whether we're going to want to focus the location bar after |
980 // this commit. We do this now because the navigation hasn't formally | 1003 // this commit. We do this now because the navigation hasn't formally |
981 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1004 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
982 // this triggers won't be able to figure out what's going on. | 1005 // this triggers won't be able to figure out what's going on. |
983 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1006 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
984 | 1007 |
985 // We expect SwapOutOldPage to have canceled any modal dialogs and told the | 1008 // We expect SwapOutOldPage to have canceled any modal dialogs and told the |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1086 } | 1109 } |
1087 | 1110 |
1088 // If the old RFH is live, we are swapping it out and should keep track of | 1111 // If the old RFH is live, we are swapping it out and should keep track of |
1089 // it in case we navigate back to it, or it is waiting for the unload event | 1112 // it in case we navigate back to it, or it is waiting for the unload event |
1090 // to execute in the background. | 1113 // to execute in the background. |
1091 // TODO(creis): Swap out the subframe in --site-per-process. | 1114 // TODO(creis): Swap out the subframe in --site-per-process. |
1092 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) | 1115 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) |
1093 DCHECK(old_render_frame_host->is_swapped_out() || | 1116 DCHECK(old_render_frame_host->is_swapped_out() || |
1094 !RenderViewHostImpl::IsRVHStateActive( | 1117 !RenderViewHostImpl::IsRVHStateActive( |
1095 old_render_frame_host->render_view_host()->rvh_state())); | 1118 old_render_frame_host->render_view_host()->rvh_state())); |
1096 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make | |
1097 // sure we don't get different rvh instances for the same site instance | |
1098 // in the same rvhmgr. | |
1099 // TODO(creis): Clean this up. | |
1100 RenderFrameProxyHostMap::iterator iter = | |
1101 proxy_hosts_.find(old_site_instance_id); | |
1102 if (iter != proxy_hosts_.end() && | |
1103 iter->second->render_frame_host() != old_render_frame_host) { | |
1104 // Delete the proxy that will be replaced in the map to avoid a leak. | |
1105 delete iter->second; | |
1106 } | |
1107 | 1119 |
1108 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, | 1120 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, |
1109 // the RenderFrameHost should be put in the map of RenderFrameHosts pending | 1121 // the RenderFrameHost should be put in the map of RenderFrameHosts pending |
1110 // shutdown. Otherwise, it is stored in the map of proxy hosts. | 1122 // shutdown. Otherwise, it is stored in the map of proxy hosts. |
1111 if (old_render_frame_host->render_view_host()->rvh_state() == | 1123 if (old_render_frame_host->render_view_host()->rvh_state() == |
1112 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { | 1124 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { |
1113 proxy_hosts_.erase(old_site_instance_id); | 1125 // The proxy for this RenderFrameHost is created when sending the |
1126 // SwapOut message, so check if it already exists and delete it. | |
1127 RenderFrameProxyHostMap::iterator iter = | |
1128 proxy_hosts_.find(old_site_instance_id); | |
1129 if (iter != proxy_hosts_.end()) { | |
1130 delete iter->second; | |
1131 proxy_hosts_.erase(iter); | |
1132 } | |
1114 RFHPendingDeleteMap::iterator pending_delete_iter = | 1133 RFHPendingDeleteMap::iterator pending_delete_iter = |
1115 pending_delete_hosts_.find(old_site_instance_id); | 1134 pending_delete_hosts_.find(old_site_instance_id); |
1116 if (pending_delete_iter == pending_delete_hosts_.end() || | 1135 if (pending_delete_iter == pending_delete_hosts_.end() || |
1117 pending_delete_iter->second.get() != old_render_frame_host) { | 1136 pending_delete_iter->second.get() != old_render_frame_host) { |
1118 pending_delete_hosts_[old_site_instance_id] = | 1137 pending_delete_hosts_[old_site_instance_id] = |
1119 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); | 1138 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); |
1120 } | 1139 } |
1121 } else { | 1140 } else { |
1141 // Capture the active view count on the old RFH SiteInstance, since the | |
1142 // ownership will be passed into the proxy and the pointer will be invalid. | |
1143 int active_view_count = | |
1144 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) | |
1145 ->active_view_count(); | |
1146 | |
1147 RenderFrameProxyHostMap::iterator iter = | |
1148 proxy_hosts_.find(old_site_instance_id); | |
1149 CHECK(iter != proxy_hosts_.end()); | |
1150 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass()); | |
1151 | |
1122 // If there are no active views in this SiteInstance, it means that | 1152 // If there are no active views in this SiteInstance, it means that |
1123 // this RFH was the last active one in the SiteInstance. Now that we | 1153 // this RFH was the last active one in the SiteInstance. Now that we |
1124 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs | 1154 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs |
1125 // in this SiteInstance. We do this after ensuring the RFH is on the | 1155 // in this SiteInstance. |
1126 // swapped out list to simplify the deletion. | 1156 if (!active_view_count) |
1127 if (!static_cast<SiteInstanceImpl*>( | |
1128 old_render_frame_host->GetSiteInstance())->active_view_count()) { | |
1129 old_render_frame_host.reset(); | |
1130 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); | 1157 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); |
1131 } else { | |
1132 proxy_hosts_[old_site_instance_id] = new RenderFrameProxyHost( | |
1133 old_render_frame_host.Pass()); | |
1134 } | |
1135 } | 1158 } |
1136 } | 1159 } |
1137 | 1160 |
1138 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( | 1161 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( |
1139 int32 site_instance_id) { | 1162 int32 site_instance_id) { |
1140 // First remove any swapped out RFH for this SiteInstance from our own list. | 1163 // First remove any swapped out RFH for this SiteInstance from our own list. |
1141 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); | 1164 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); |
1142 | 1165 |
1143 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | 1166 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts |
1144 // in the SiteInstance, then tell their respective FrameTrees to remove all | 1167 // in the SiteInstance, then tell their respective FrameTrees to remove all |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 pending_render_frame_host->GetProcess()->RemovePendingView(); | 1359 pending_render_frame_host->GetProcess()->RemovePendingView(); |
1337 | 1360 |
1338 // If the SiteInstance for the pending RFH is being used by others, don't | 1361 // If the SiteInstance for the pending RFH is being used by others, don't |
1339 // delete the RFH, just swap it out and it can be reused at a later point. | 1362 // delete the RFH, just swap it out and it can be reused at a later point. |
1340 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( | 1363 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( |
1341 pending_render_frame_host->GetSiteInstance()); | 1364 pending_render_frame_host->GetSiteInstance()); |
1342 if (site_instance->active_view_count() > 1) { | 1365 if (site_instance->active_view_count() > 1) { |
1343 // Any currently suspended navigations are no longer needed. | 1366 // Any currently suspended navigations are no longer needed. |
1344 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); | 1367 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); |
1345 | 1368 |
1346 pending_render_frame_host->SwapOut(); | 1369 RenderFrameProxyHost* proxy = |
1347 | 1370 new RenderFrameProxyHost(site_instance, frame_tree_node_); |
1348 proxy_hosts_[site_instance->GetId()] = new RenderFrameProxyHost( | 1371 proxy_hosts_[site_instance->GetId()] = proxy; |
1349 pending_render_frame_host.Pass()); | 1372 pending_render_frame_host->SwapOut(proxy); |
1373 proxy->TakeFrameHostOwnership(pending_render_frame_host.Pass()); | |
1350 } else { | 1374 } else { |
1351 // We won't be coming back, so delete this one. | 1375 // We won't be coming back, so delete this one. |
1352 pending_render_frame_host.reset(); | 1376 pending_render_frame_host.reset(); |
1353 } | 1377 } |
1354 | 1378 |
1355 pending_web_ui_.reset(); | 1379 pending_web_ui_.reset(); |
1356 pending_and_current_web_ui_.reset(); | 1380 pending_and_current_web_ui_.reset(); |
1357 } | 1381 } |
1358 | 1382 |
1359 bool RenderFrameHostManager::IsRVHOnSwappedOutList( | 1383 bool RenderFrameHostManager::IsRVHOnSwappedOutList( |
(...skipping 30 matching lines...) Expand all Loading... | |
1390 SiteInstance* instance) const { | 1414 SiteInstance* instance) const { |
1391 RenderFrameProxyHostMap::const_iterator iter = | 1415 RenderFrameProxyHostMap::const_iterator iter = |
1392 proxy_hosts_.find(instance->GetId()); | 1416 proxy_hosts_.find(instance->GetId()); |
1393 if (iter != proxy_hosts_.end()) | 1417 if (iter != proxy_hosts_.end()) |
1394 return iter->second; | 1418 return iter->second; |
1395 | 1419 |
1396 return NULL; | 1420 return NULL; |
1397 } | 1421 } |
1398 | 1422 |
1399 } // namespace content | 1423 } // namespace content |
OLD | NEW |