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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 } | 329 } |
| 330 | 330 |
| 331 void RenderFrameHostManager::OnCrossSiteResponse( | 331 void RenderFrameHostManager::OnCrossSiteResponse( |
| 332 RenderFrameHostImpl* pending_render_frame_host, | 332 RenderFrameHostImpl* pending_render_frame_host, |
| 333 const GlobalRequestID& global_request_id, | 333 const GlobalRequestID& global_request_id, |
| 334 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, | 334 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, |
| 335 const std::vector<GURL>& transfer_url_chain, | 335 const std::vector<GURL>& transfer_url_chain, |
| 336 const Referrer& referrer, | 336 const Referrer& referrer, |
| 337 PageTransition page_transition, | 337 PageTransition page_transition, |
| 338 bool should_replace_current_entry) { | 338 bool should_replace_current_entry) { |
| 339 LOG(ERROR) << "RFHM::OnCrossSiteResponse[" << this << "]"; | |
| 339 // This should be called either when the pending RFH is ready to commit or | 340 // This should be called either when the pending RFH is ready to commit or |
| 340 // when we realize that the current RFH's request requires a transfer. | 341 // when we realize that the current RFH's request requires a transfer. |
| 341 DCHECK(pending_render_frame_host == pending_render_frame_host_ || | 342 DCHECK(pending_render_frame_host == pending_render_frame_host_ || |
| 342 pending_render_frame_host == render_frame_host_); | 343 pending_render_frame_host == render_frame_host_); |
| 343 | 344 |
| 344 // TODO(creis): Eventually we will want to check all navigation responses | 345 // TODO(creis): Eventually we will want to check all navigation responses |
| 345 // here, but currently we pass information for a transfer if | 346 // here, but currently we pass information for a transfer if |
| 346 // ShouldSwapProcessesForRedirect returned true in the network stack. | 347 // ShouldSwapProcessesForRedirect returned true in the network stack. |
| 347 // In that case, we should set up a transfer after the unload handler runs. | 348 // In that case, we should set up a transfer after the unload handler runs. |
| 348 // If |cross_site_transferring_request| is NULL, we will just run the unload | 349 // If |cross_site_transferring_request| is NULL, we will just run the unload |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 // from the map and not leaked. | 531 // from the map and not leaked. |
| 531 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( | 532 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( |
| 532 render_frame_host_->GetSiteInstance()->GetId()); | 533 render_frame_host_->GetSiteInstance()->GetId()); |
| 533 if (iter != proxy_hosts_.end()) { | 534 if (iter != proxy_hosts_.end()) { |
| 534 delete iter->second; | 535 delete iter->second; |
| 535 proxy_hosts_.erase(iter); | 536 proxy_hosts_.erase(iter); |
| 536 } | 537 } |
| 537 | 538 |
| 538 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 539 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
| 539 render_frame_host_->GetSiteInstance(), frame_tree_node_); | 540 render_frame_host_->GetSiteInstance(), frame_tree_node_); |
| 540 proxy_hosts_[render_frame_host_->GetSiteInstance()->GetId()] = proxy; | 541 std::pair<RenderFrameProxyHostMap::iterator, bool> result = |
| 542 proxy_hosts_.insert(std::make_pair( | |
| 543 render_frame_host_->GetSiteInstance()->GetId(), proxy)); | |
| 544 CHECK(result.second) << "Inserting a duplicate item."; | |
| 541 | 545 |
| 542 // Tell the old frame it is being swapped out. This will fire the unload | 546 // Tell the old frame it is being swapped out. This will fire the unload |
| 543 // handler in the background (without firing the beforeunload handler a second | 547 // handler in the background (without firing the beforeunload handler a second |
| 544 // time). When the navigation completes, we will send a message to the | 548 // time). When the navigation completes, we will send a message to the |
| 545 // ResourceDispatcherHost, allowing the pending RVH's response to resume. | 549 // ResourceDispatcherHost, allowing the pending RVH's response to resume. |
| 546 render_frame_host_->SwapOut(proxy); | 550 render_frame_host_->SwapOut(proxy); |
| 547 | 551 |
| 548 // ResourceDispatcherHost has told us to run the onunload handler, which | 552 // ResourceDispatcherHost has told us to run the onunload handler, which |
| 549 // means it is not a download or unsafe page, and we are going to perform the | 553 // means it is not a download or unsafe page, and we are going to perform the |
| 550 // navigation. Thus, we no longer need to remember that the RenderFrameHost | 554 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 | 877 |
| 874 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( | 878 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( |
| 875 SiteInstance* site_instance, | 879 SiteInstance* site_instance, |
| 876 int view_routing_id, | 880 int view_routing_id, |
| 877 int frame_routing_id, | 881 int frame_routing_id, |
| 878 bool swapped_out, | 882 bool swapped_out, |
| 879 bool hidden) { | 883 bool hidden) { |
| 880 if (frame_routing_id == MSG_ROUTING_NONE) | 884 if (frame_routing_id == MSG_ROUTING_NONE) |
| 881 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); | 885 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); |
| 882 | 886 |
| 883 // Create a RVH for main frames, or find the existing one for subframes. | 887 // Create a RVH for the new frame or find an existing one. |
| 884 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 888 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
| 885 RenderViewHostImpl* render_view_host = NULL; | 889 RenderViewHostImpl* render_view_host = |
| 886 if (frame_tree_node_->IsMainFrame()) { | 890 frame_tree->GetRenderViewHost(site_instance); |
| 887 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( | 891 LOG(ERROR) << "RFHM::CreateRenderFrameHost[" << this << "]:" |
| 892 << " routing_id: " << frame_routing_id | |
| 893 << ", rvh: " << render_view_host | |
| 894 << ", swapped_out: " << swapped_out; | |
| 895 if (!render_view_host) { | |
| 896 render_view_host = frame_tree->CreateRenderViewHost( | |
| 888 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); | 897 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); |
| 889 } else { | |
| 890 render_view_host = frame_tree->GetRenderViewHostForSubFrame(site_instance); | |
| 891 | |
| 892 // If we haven't found a RVH for a subframe RFH, it's because we currently | |
| 893 // do not create top-level RFHs for pending subframe navigations. Create | |
| 894 // the RVH here for now. | |
| 895 // TODO(creis): Mirror the frame tree so this check isn't necessary. | |
| 896 if (!render_view_host) { | |
| 897 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( | |
| 898 site_instance, view_routing_id, frame_routing_id, swapped_out, | |
| 899 hidden); | |
| 900 } | |
| 901 } | 898 } |
| 902 | 899 |
| 903 // TODO(creis): Pass hidden to RFH. | 900 // TODO(creis): Pass hidden to RFH. |
| 904 scoped_ptr<RenderFrameHostImpl> render_frame_host = | 901 scoped_ptr<RenderFrameHostImpl> render_frame_host = |
| 905 make_scoped_ptr(RenderFrameHostFactory::Create(render_view_host, | 902 make_scoped_ptr(RenderFrameHostFactory::Create(render_view_host, |
| 906 render_frame_delegate_, | 903 render_frame_delegate_, |
| 907 frame_tree, | 904 frame_tree, |
| 908 frame_tree_node_, | 905 frame_tree_node_, |
| 909 frame_routing_id, | 906 frame_routing_id, |
| 910 swapped_out).release()); | 907 swapped_out).release()); |
| 911 return render_frame_host.Pass(); | 908 return render_frame_host.Pass(); |
| 912 } | 909 } |
| 913 | 910 |
| 914 int RenderFrameHostManager::CreateRenderFrame( | 911 int RenderFrameHostManager::CreateRenderFrame( |
| 915 SiteInstance* instance, | 912 SiteInstance* instance, |
| 916 int opener_route_id, | 913 int opener_route_id, |
| 917 bool swapped_out, | 914 bool swapped_out, |
| 918 bool hidden) { | 915 bool hidden) { |
| 919 CHECK(instance); | 916 CHECK(instance); |
| 920 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. | 917 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. |
| 921 | 918 |
| 919 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" | |
| 920 << " site:" << instance->GetSiteURL() << ", swapped:" << swapped_out; | |
| 921 | |
| 922 // TODO(nasko): Remove this check once cross-site navigation no longer | |
| 923 // relies on swapped out RFH for the top-level frame. | |
| 924 if (!frame_tree_node_->IsMainFrame()) { | |
| 925 CHECK(!swapped_out); | |
| 926 } | |
| 927 | |
| 922 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 928 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
| 923 RenderFrameHostImpl* frame_to_announce = NULL; | 929 RenderFrameHostImpl* frame_to_announce = NULL; |
| 924 int routing_id = MSG_ROUTING_NONE; | 930 int routing_id = MSG_ROUTING_NONE; |
| 925 | 931 |
| 926 // We are creating a pending or swapped out RFH here. We should never create | 932 // We are creating a pending or swapped out RFH here. We should never create |
| 927 // it in the same SiteInstance as our current RFH. | 933 // it in the same SiteInstance as our current RFH. |
| 928 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 934 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
| 929 | 935 |
| 930 // Check if we've already created an RFH for this SiteInstance. If so, try | 936 // Check if we've already created an RFH for this SiteInstance. If so, try |
| 931 // to re-use the existing one, which has already been initialized. We'll | 937 // to re-use the existing one, which has already been initialized. We'll |
| 932 // remove it from the list of swapped out hosts if it commits. | 938 // remove it from the list of swapped out hosts if it commits. |
| 933 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 939 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 934 | 940 |
| 935 if (proxy) { | 941 if (proxy) { |
| 936 routing_id = proxy->GetRenderViewHost()->GetRoutingID(); | 942 routing_id = proxy->GetRoutingID(); |
| 943 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" | |
| 944 << " proxy exists: " << routing_id; | |
| 937 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 945 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
| 938 // Prevent the process from exiting while we're trying to use it. | 946 // Prevent the process from exiting while we're trying to use it. |
| 939 if (!swapped_out) { | 947 if (!swapped_out) { |
| 940 new_render_frame_host = proxy->PassFrameHostOwnership(); | 948 new_render_frame_host = proxy->PassFrameHostOwnership(); |
| 941 new_render_frame_host->GetProcess()->AddPendingView(); | 949 new_render_frame_host->GetProcess()->AddPendingView(); |
| 942 | 950 |
| 943 proxy_hosts_.erase(instance->GetId()); | 951 proxy_hosts_.erase(instance->GetId()); |
| 944 delete proxy; | 952 delete proxy; |
| 945 | 953 |
| 946 // When a new render view is created by the renderer, the new WebContents | 954 // When a new render view is created by the renderer, the new WebContents |
| 947 // gets a RenderViewHost in the SiteInstance of its opener WebContents. | 955 // gets a RenderViewHost in the SiteInstance of its opener WebContents. |
| 948 // If not used in the first navigation, this RVH is swapped out and is not | 956 // If not used in the first navigation, this RVH is swapped out and is not |
| 949 // granted bindings, so we may need to grant them when swapping it in. | 957 // granted bindings, so we may need to grant them when swapping it in. |
| 950 if (pending_web_ui() && | 958 if (pending_web_ui() && |
| 951 !new_render_frame_host->GetProcess()->IsIsolatedGuest()) { | 959 !new_render_frame_host->GetProcess()->IsIsolatedGuest()) { |
| 952 int required_bindings = pending_web_ui()->GetBindings(); | 960 int required_bindings = pending_web_ui()->GetBindings(); |
| 953 RenderViewHost* rvh = new_render_frame_host->render_view_host(); | 961 RenderViewHost* rvh = new_render_frame_host->render_view_host(); |
| 954 if ((rvh->GetEnabledBindings() & required_bindings) != | 962 if ((rvh->GetEnabledBindings() & required_bindings) != |
| 955 required_bindings) { | 963 required_bindings) { |
| 956 rvh->AllowBindings(required_bindings); | 964 rvh->AllowBindings(required_bindings); |
| 957 } | 965 } |
| 958 } | 966 } |
| 959 } | 967 } |
| 960 } else { | 968 } else { |
| 969 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" | |
| 970 << " creating new RFH"; | |
| 961 // Create a new RenderFrameHost if we don't find an existing one. | 971 // Create a new RenderFrameHost if we don't find an existing one. |
| 962 new_render_frame_host = CreateRenderFrameHost( | 972 new_render_frame_host = CreateRenderFrameHost( |
| 963 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); | 973 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); |
| 964 RenderViewHostImpl* render_view_host = | 974 RenderViewHostImpl* render_view_host = |
| 965 new_render_frame_host->render_view_host(); | 975 new_render_frame_host->render_view_host(); |
| 966 int proxy_routing_id = MSG_ROUTING_NONE; | 976 int proxy_routing_id = MSG_ROUTING_NONE; |
| 967 | 977 |
| 968 // Prevent the process from exiting while we're trying to navigate in it. | 978 // Prevent the process from exiting while we're trying to navigate in it. |
| 969 // Otherwise, if the new RFH is swapped out already, store it. | 979 // Otherwise, if the new RFH is swapped out already, store it. |
| 970 if (!swapped_out) { | 980 if (!swapped_out) { |
| 971 new_render_frame_host->GetProcess()->AddPendingView(); | 981 new_render_frame_host->GetProcess()->AddPendingView(); |
| 972 } else { | 982 } else { |
| 973 proxy = new RenderFrameProxyHost( | 983 proxy = new RenderFrameProxyHost( |
| 974 new_render_frame_host->GetSiteInstance(), frame_tree_node_); | 984 new_render_frame_host->GetSiteInstance(), frame_tree_node_); |
| 975 proxy_hosts_[instance->GetId()] = proxy; | 985 proxy_hosts_[instance->GetId()] = proxy; |
| 976 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 986 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
| 977 proxy_routing_id = proxy->GetRoutingID(); | 987 proxy_routing_id = proxy->GetRoutingID(); |
| 978 } | 988 } |
| 979 | 989 |
| 980 bool success = InitRenderView( | 990 bool success = InitRenderView( |
| 981 render_view_host, opener_route_id, proxy_routing_id, | 991 render_view_host, opener_route_id, proxy_routing_id, |
| 982 frame_tree_node_->IsMainFrame()); | 992 frame_tree_node_->IsMainFrame()); |
| 983 if (success && frame_tree_node_->IsMainFrame()) { | 993 if (success) { |
| 984 // Don't show the main frame's view until we get a DidNavigate from it. | 994 if (frame_tree_node_->IsMainFrame()) { |
| 985 render_view_host->GetView()->Hide(); | 995 // Don't show the main frame's view until we get a DidNavigate from it. |
| 996 render_view_host->GetView()->Hide(); | |
| 997 } else if (!swapped_out) { | |
| 998 // Init the RFH, so a RenderFrame is created in the renderer. | |
| 999 DCHECK(new_render_frame_host.get()); | |
| 1000 success = InitRenderFrame(new_render_frame_host.get()); | |
| 1001 } | |
| 1002 if (swapped_out) { | |
| 1003 proxy_hosts_[instance->GetId()]->InitRenderFrameProxy(); | |
| 1004 } | |
| 986 } else if (!swapped_out && pending_render_frame_host_) { | 1005 } else if (!swapped_out && pending_render_frame_host_) { |
| 987 CancelPending(); | 1006 CancelPending(); |
| 988 } | 1007 } |
| 989 routing_id = render_view_host->GetRoutingID(); | 1008 routing_id = render_view_host->GetRoutingID(); |
| 990 frame_to_announce = new_render_frame_host.get(); | 1009 frame_to_announce = new_render_frame_host.get(); |
| 991 } | 1010 } |
| 992 | 1011 |
| 993 // Use this as our new pending RFH if it isn't swapped out. | 1012 // Use this as our new pending RFH if it isn't swapped out. |
| 994 if (!swapped_out) | 1013 if (!swapped_out) |
| 995 pending_render_frame_host_ = new_render_frame_host.Pass(); | 1014 pending_render_frame_host_ = new_render_frame_host.Pass(); |
| 996 | 1015 |
| 997 // If a brand new RFH was created, announce it to observers. | 1016 // If a brand new RFH was created, announce it to observers. |
| 998 if (frame_to_announce) | 1017 if (frame_to_announce) |
| 999 render_frame_delegate_->RenderFrameCreated(frame_to_announce); | 1018 render_frame_delegate_->RenderFrameCreated(frame_to_announce); |
| 1000 | 1019 |
| 1020 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" | |
| 1021 << "complete: " << routing_id; | |
| 1022 | |
| 1001 return routing_id; | 1023 return routing_id; |
| 1002 } | 1024 } |
| 1003 | 1025 |
| 1026 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance, | |
| 1027 int opener_route_id) { | |
| 1028 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" | |
| 1029 << " " << instance->GetSiteURL(); | |
| 1030 | |
| 1031 // A RenderFrameProxyHost should never be created in the same SiteInstance as | |
| 1032 // the current RFH. | |
| 1033 CHECK(instance); | |
| 1034 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); | |
| 1035 | |
| 1036 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | |
| 1037 if (proxy) { | |
| 1038 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" | |
| 1039 << " found existing proxy"; | |
| 1040 return proxy->GetRoutingID(); | |
| 1041 } | |
| 1042 | |
| 1043 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" | |
| 1044 << " creating new proxy"; | |
| 1045 proxy = new RenderFrameProxyHost(instance, frame_tree_node_); | |
| 1046 proxy_hosts_[instance->GetId()] = proxy; | |
|
ncarter (slow)
2014/06/25 01:07:56
Probably worthwhile to insert while checking for d
| |
| 1047 proxy->InitRenderFrameProxy(); | |
| 1048 return proxy->GetRoutingID(); | |
| 1049 } | |
| 1050 | |
| 1004 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, | 1051 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, |
| 1005 int opener_route_id, | 1052 int opener_route_id, |
| 1006 int proxy_routing_id, | 1053 int proxy_routing_id, |
| 1007 bool for_main_frame) { | 1054 bool for_main_frame) { |
| 1008 // We may have initialized this RenderViewHost for another RenderFrameHost. | 1055 // We may have initialized this RenderViewHost for another RenderFrameHost. |
| 1009 if (render_view_host->IsRenderViewLive()) | 1056 if (render_view_host->IsRenderViewLive()) |
| 1010 return true; | 1057 return true; |
| 1011 | 1058 |
| 1012 // If the pending navigation is to a WebUI and the RenderView is not in a | 1059 // If the pending navigation is to a WebUI and the RenderView is not in a |
| 1013 // guest process, tell the RenderViewHost about any bindings it will need | 1060 // guest process, tell the RenderViewHost about any bindings it will need |
| 1014 // enabled. | 1061 // enabled. |
| 1015 if (pending_web_ui() && !render_view_host->GetProcess()->IsIsolatedGuest()) { | 1062 if (pending_web_ui() && !render_view_host->GetProcess()->IsIsolatedGuest()) { |
| 1016 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); | 1063 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); |
| 1017 } else { | 1064 } else { |
| 1018 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled | 1065 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled |
| 1019 // process unless it's swapped out. | 1066 // process unless it's swapped out. |
| 1020 RenderViewHostImpl* rvh_impl = | 1067 RenderViewHostImpl* rvh_impl = |
| 1021 static_cast<RenderViewHostImpl*>(render_view_host); | 1068 static_cast<RenderViewHostImpl*>(render_view_host); |
| 1022 if (!rvh_impl->IsSwappedOut()) { | 1069 if (!rvh_impl->IsSwappedOut()) { |
| 1023 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1070 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 1024 render_view_host->GetProcess()->GetID())); | 1071 render_view_host->GetProcess()->GetID())); |
| 1025 } | 1072 } |
| 1026 } | 1073 } |
| 1027 | 1074 |
| 1028 return delegate_->CreateRenderViewForRenderManager( | 1075 return delegate_->CreateRenderViewForRenderManager( |
| 1029 render_view_host, opener_route_id, proxy_routing_id, for_main_frame); | 1076 render_view_host, opener_route_id, proxy_routing_id, for_main_frame); |
| 1030 } | 1077 } |
| 1031 | 1078 |
| 1079 bool RenderFrameHostManager::InitRenderFrame( | |
| 1080 RenderFrameHost* render_frame_host) { | |
| 1081 RenderFrameHostImpl* rfh = | |
| 1082 static_cast<RenderFrameHostImpl*>(render_frame_host); | |
| 1083 if (rfh->IsRenderFrameLive()) | |
| 1084 return true; | |
| 1085 | |
| 1086 int parent_routing_id = MSG_ROUTING_NONE; | |
| 1087 if (frame_tree_node_->parent()) { | |
| 1088 parent_routing_id = frame_tree_node_->parent()->render_manager()-> | |
| 1089 GetRoutingIdForSiteInstance(render_frame_host->GetSiteInstance()); | |
| 1090 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); | |
| 1091 } | |
| 1092 return delegate_->CreateRenderFrameForRenderManager( | |
| 1093 render_frame_host, parent_routing_id); | |
| 1094 } | |
| 1095 | |
| 1096 int RenderFrameHostManager::GetRoutingIdForSiteInstance( | |
| 1097 SiteInstance* site_instance) { | |
| 1098 if (render_frame_host_->GetSiteInstance() == site_instance) | |
| 1099 return render_frame_host_->GetRoutingID(); | |
| 1100 | |
| 1101 RenderFrameProxyHostMap::iterator iter = | |
| 1102 proxy_hosts_.find(site_instance->GetId()); | |
| 1103 if (iter != proxy_hosts_.end()) | |
| 1104 return iter->second->GetRoutingID(); | |
| 1105 | |
| 1106 return MSG_ROUTING_NONE; | |
| 1107 } | |
| 1108 | |
| 1032 void RenderFrameHostManager::CommitPending() { | 1109 void RenderFrameHostManager::CommitPending() { |
| 1033 // First check whether we're going to want to focus the location bar after | 1110 // First check whether we're going to want to focus the location bar after |
| 1034 // this commit. We do this now because the navigation hasn't formally | 1111 // this commit. We do this now because the navigation hasn't formally |
| 1035 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1112 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
| 1036 // this triggers won't be able to figure out what's going on. | 1113 // this triggers won't be able to figure out what's going on. |
| 1037 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1114 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
| 1038 | 1115 |
| 1039 // We expect SwapOutOldPage to have canceled any modal dialogs and told the | 1116 // We expect SwapOutOldPage to have canceled any modal dialogs and told the |
| 1040 // renderer to suppress any further dialogs until it is swapped out. However, | 1117 // renderer to suppress any further dialogs until it is swapped out. However, |
| 1041 // crash reports indicate that it's still possible for modal dialogs to exist | 1118 // crash reports indicate that it's still possible for modal dialogs to exist |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 | 1217 |
| 1141 // If the old RFH is live, we are swapping it out and should keep track of | 1218 // If the old RFH is live, we are swapping it out and should keep track of |
| 1142 // it in case we navigate back to it, or it is waiting for the unload event | 1219 // it in case we navigate back to it, or it is waiting for the unload event |
| 1143 // to execute in the background. | 1220 // to execute in the background. |
| 1144 // TODO(creis): Swap out the subframe in --site-per-process. | 1221 // TODO(creis): Swap out the subframe in --site-per-process. |
| 1145 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) | 1222 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) |
| 1146 DCHECK(old_render_frame_host->is_swapped_out() || | 1223 DCHECK(old_render_frame_host->is_swapped_out() || |
| 1147 !RenderViewHostImpl::IsRVHStateActive( | 1224 !RenderViewHostImpl::IsRVHStateActive( |
| 1148 old_render_frame_host->render_view_host()->rvh_state())); | 1225 old_render_frame_host->render_view_host()->rvh_state())); |
| 1149 | 1226 |
| 1150 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, | 1227 // TODO(nasko): To keep it simple for now, just split the logic in top-level |
| 1151 // the RenderFrameHost should be put in the map of RenderFrameHosts pending | 1228 // vs subframe. |
| 1152 // shutdown. Otherwise, it is stored in the map of proxy hosts. | 1229 if (is_main_frame) { |
| 1153 if (old_render_frame_host->render_view_host()->rvh_state() == | 1230 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, |
| 1154 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { | 1231 // the RenderFrameHost should be put in the map of RenderFrameHosts pending |
| 1155 // The proxy for this RenderFrameHost is created when sending the | 1232 // shutdown. Otherwise, it is stored in the map of proxy hosts. |
| 1156 // SwapOut message, so check if it already exists and delete it. | 1233 if (old_render_frame_host->render_view_host()->rvh_state() == |
| 1157 RenderFrameProxyHostMap::iterator iter = | 1234 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { |
| 1158 proxy_hosts_.find(old_site_instance_id); | 1235 // The proxy for this RenderFrameHost is created when sending the |
| 1159 if (iter != proxy_hosts_.end()) { | 1236 // SwapOut message, so check if it already exists and delete it. |
| 1160 delete iter->second; | 1237 RenderFrameProxyHostMap::iterator iter = |
| 1161 proxy_hosts_.erase(iter); | 1238 proxy_hosts_.find(old_site_instance_id); |
| 1162 } | 1239 if (iter != proxy_hosts_.end()) { |
| 1163 RFHPendingDeleteMap::iterator pending_delete_iter = | 1240 delete iter->second; |
| 1164 pending_delete_hosts_.find(old_site_instance_id); | 1241 proxy_hosts_.erase(iter); |
| 1165 if (pending_delete_iter == pending_delete_hosts_.end() || | 1242 } |
| 1166 pending_delete_iter->second.get() != old_render_frame_host) { | 1243 RFHPendingDeleteMap::iterator pending_delete_iter = |
| 1167 pending_delete_hosts_[old_site_instance_id] = | 1244 pending_delete_hosts_.find(old_site_instance_id); |
| 1168 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); | 1245 if (pending_delete_iter == pending_delete_hosts_.end() || |
| 1169 } | 1246 pending_delete_iter->second.get() != old_render_frame_host) { |
| 1170 } else { | 1247 pending_delete_hosts_[old_site_instance_id] = |
| 1171 // Capture the active view count on the old RFH SiteInstance, since the | 1248 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); |
| 1172 // ownership will be passed into the proxy and the pointer will be invalid. | 1249 } |
| 1173 int active_view_count = | 1250 } else { |
| 1174 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) | 1251 // Capture the active view count on the old RFH SiteInstance, since the |
| 1175 ->active_view_count(); | 1252 // ownership will be passed into the proxy and the pointer will be |
| 1253 // invalid. | |
| 1254 int active_view_count = | |
| 1255 static_cast<SiteInstanceImpl*>( | |
| 1256 old_render_frame_host->GetSiteInstance())->active_view_count(); | |
| 1176 | 1257 |
| 1177 RenderFrameProxyHostMap::iterator iter = | 1258 RenderFrameProxyHostMap::iterator iter = |
| 1178 proxy_hosts_.find(old_site_instance_id); | 1259 proxy_hosts_.find(old_site_instance_id); |
| 1179 CHECK(iter != proxy_hosts_.end()); | 1260 CHECK(iter != proxy_hosts_.end()); |
| 1180 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass()); | 1261 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass()); |
| 1181 | 1262 |
| 1182 // If there are no active views in this SiteInstance, it means that | 1263 // If there are no active views in this SiteInstance, it means that |
| 1183 // this RFH was the last active one in the SiteInstance. Now that we | 1264 // this RFH was the last active one in the SiteInstance. Now that we |
| 1184 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs | 1265 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs |
| 1185 // in this SiteInstance. | 1266 // in this SiteInstance. |
| 1186 if (!active_view_count) { | 1267 if (!active_view_count) { |
| 1187 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); | 1268 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); |
| 1188 } else { | 1269 } else { |
| 1189 // If this is a subframe, it should have a CrossProcessFrameConnector | 1270 // If this is a subframe, it should have a CrossProcessFrameConnector |
| 1190 // created already and we just need to link it to the proper view in the | 1271 // created already and we just need to link it to the proper view in the |
| 1191 // new process. | 1272 // new process. |
| 1192 if (!is_main_frame) { | 1273 if (!is_main_frame) { |
| 1193 RenderFrameProxyHost* proxy = GetProxyToParent(); | 1274 RenderFrameProxyHost* proxy = GetProxyToParent(); |
| 1194 if (proxy) { | 1275 if (proxy) { |
| 1195 proxy->SetChildRWHView( | 1276 proxy->SetChildRWHView( |
| 1196 render_frame_host_->render_view_host()->GetView()); | 1277 render_frame_host_->render_view_host()->GetView()); |
| 1278 } | |
| 1197 } | 1279 } |
| 1198 } | 1280 } |
| 1199 } | 1281 } |
| 1282 } else { | |
| 1283 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == | |
| 1284 proxy_hosts_.end()); | |
| 1285 | |
| 1286 // If the old frame has already completed running the unload handler, | |
| 1287 // it is safe to just delete immediately. Otherwise, add it to the list | |
| 1288 // of frames pending deletion. | |
| 1289 if (old_render_frame_host->has_received_swap_out_ack()) { | |
| 1290 old_render_frame_host.reset(NULL); | |
| 1291 } else { | |
| 1292 // Put the old RFH on the list of hosts pending deletion. | |
| 1293 RFHPendingDeleteMap::iterator pending_delete_iter = | |
| 1294 pending_delete_hosts_.find(old_site_instance_id); | |
| 1295 if (pending_delete_iter == pending_delete_hosts_.end() || | |
| 1296 pending_delete_iter->second.get() != old_render_frame_host) { | |
| 1297 pending_delete_hosts_[old_site_instance_id] = | |
| 1298 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); | |
| 1299 } | |
| 1300 } | |
| 1200 } | 1301 } |
| 1201 } | 1302 } |
| 1202 | 1303 |
| 1203 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( | 1304 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( |
| 1204 int32 site_instance_id) { | 1305 int32 site_instance_id) { |
| 1205 // First remove any swapped out RFH for this SiteInstance from our own list. | 1306 // First remove any swapped out RFH for this SiteInstance from our own list. |
| 1206 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); | 1307 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); |
| 1207 | 1308 |
| 1208 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | 1309 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts |
| 1209 // in the SiteInstance, then tell their respective FrameTrees to remove all | 1310 // in the SiteInstance, then tell their respective FrameTrees to remove all |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1231 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 1332 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
| 1232 const NavigationEntryImpl& entry) { | 1333 const NavigationEntryImpl& entry) { |
| 1233 // If we are currently navigating cross-process, we want to get back to normal | 1334 // If we are currently navigating cross-process, we want to get back to normal |
| 1234 // and then navigate as usual. | 1335 // and then navigate as usual. |
| 1235 if (cross_navigation_pending_) { | 1336 if (cross_navigation_pending_) { |
| 1236 if (pending_render_frame_host_) | 1337 if (pending_render_frame_host_) |
| 1237 CancelPending(); | 1338 CancelPending(); |
| 1238 cross_navigation_pending_ = false; | 1339 cross_navigation_pending_ = false; |
| 1239 } | 1340 } |
| 1240 | 1341 |
| 1241 // render_frame_host_'s SiteInstance and new_instance will not be deleted | 1342 // render_frame_host_'s SiteInstance will not be deleted before the end of |
| 1242 // before the end of this method, so we don't have to worry about their ref | 1343 // this method, so we don't have to worry about the ref count dropping to |
| 1243 // counts dropping to zero. | 1344 // zero. The new_instance is possibly passed to CreateProxiesForSiteInstance, |
| 1345 // which expects properly ref-counted object, so use a scoped_refptr for it. | |
| 1244 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1346 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 1245 SiteInstance* new_instance = current_instance; | 1347 scoped_refptr<SiteInstance> new_instance(current_instance); |
| 1246 | 1348 |
| 1247 // We do not currently swap processes for navigations in webview tag guests. | 1349 // We do not currently swap processes for navigations in webview tag guests. |
| 1248 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); | 1350 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); |
| 1249 | 1351 |
| 1250 // Determine if we need a new BrowsingInstance for this entry. If true, this | 1352 // Determine if we need a new BrowsingInstance for this entry. If true, this |
| 1251 // implies that it will get a new SiteInstance (and likely process), and that | 1353 // implies that it will get a new SiteInstance (and likely process), and that |
| 1252 // other tabs in the current BrowsingInstance will be unable to script it. | 1354 // other tabs in the current BrowsingInstance will be unable to script it. |
| 1253 // This is used for cases that require a process swap even in the | 1355 // This is used for cases that require a process swap even in the |
| 1254 // process-per-tab model, such as WebUI pages. | 1356 // process-per-tab model, such as WebUI pages. |
| 1255 const NavigationEntry* current_entry = | 1357 const NavigationEntry* current_entry = |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1277 // not have its bindings set appropriately. | 1379 // not have its bindings set appropriately. |
| 1278 SetPendingWebUI(entry); | 1380 SetPendingWebUI(entry); |
| 1279 | 1381 |
| 1280 // Ensure that we have created RFHs for the new RFH's opener chain if | 1382 // Ensure that we have created RFHs for the new RFH's opener chain if |
| 1281 // we are staying in the same BrowsingInstance. This allows the pending RFH | 1383 // we are staying in the same BrowsingInstance. This allows the pending RFH |
| 1282 // to send cross-process script calls to its opener(s). | 1384 // to send cross-process script calls to its opener(s). |
| 1283 int opener_route_id = MSG_ROUTING_NONE; | 1385 int opener_route_id = MSG_ROUTING_NONE; |
| 1284 if (new_instance->IsRelatedSiteInstance(current_instance)) { | 1386 if (new_instance->IsRelatedSiteInstance(current_instance)) { |
| 1285 opener_route_id = | 1387 opener_route_id = |
| 1286 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); | 1388 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); |
| 1389 | |
| 1390 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1391 switches::kSitePerProcess)) { | |
| 1392 // Create the swapped out RVH for the new SiteInstance. This will create | |
| 1393 // a top-level swapped out RFH as well, which will be wrapped by a | |
| 1394 // RenderFrameProxyHost in the subsequent call to create proxies. | |
| 1395 if (!frame_tree_node_->IsMainFrame()) { | |
| 1396 RenderViewHostImpl* render_view_host = | |
| 1397 frame_tree_node_->frame_tree()->GetRenderViewHost( | |
| 1398 new_instance); | |
| 1399 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" | |
| 1400 << " rvh: " << render_view_host; | |
| 1401 if (!render_view_host) { | |
| 1402 frame_tree_node_->frame_tree()->root()->render_manager() | |
| 1403 ->CreateRenderFrame(new_instance, MSG_ROUTING_NONE, true, true); | |
| 1404 } | |
| 1405 } | |
| 1406 | |
| 1407 // Ensure that the frame tree has RenderFrameProxyHosts for the new | |
| 1408 // SiteInstance in all nodes except the current one. | |
| 1409 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | |
| 1410 frame_tree_node_, new_instance); | |
| 1411 } | |
| 1287 } | 1412 } |
| 1288 | 1413 |
| 1289 // Create a non-swapped-out pending RFH with the given opener and navigate | 1414 // Create a non-swapped-out pending RFH with the given opener and navigate |
| 1290 // it. | 1415 // it. |
| 1291 int route_id = CreateRenderFrame(new_instance, opener_route_id, false, | 1416 int route_id = CreateRenderFrame(new_instance, opener_route_id, false, |
| 1292 delegate_->IsHidden()); | 1417 delegate_->IsHidden()); |
| 1293 if (route_id == MSG_ROUTING_NONE) | 1418 if (route_id == MSG_ROUTING_NONE) |
| 1294 return NULL; | 1419 return NULL; |
| 1295 | 1420 |
| 1296 // Check if our current RFH is live before we set up a transition. | 1421 // Check if our current RFH is live before we set up a transition. |
| 1297 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { | 1422 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { |
| 1423 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" | |
| 1424 << " rvh isn't live"; | |
| 1298 if (!cross_navigation_pending_) { | 1425 if (!cross_navigation_pending_) { |
| 1426 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" | |
| 1427 << " !cross_nav_pending_, will CommitPending"; | |
| 1299 // The current RFH is not live. There's no reason to sit around with a | 1428 // The current RFH is not live. There's no reason to sit around with a |
| 1300 // sad tab or a newly created RFH while we wait for the pending RFH to | 1429 // sad tab or a newly created RFH while we wait for the pending RFH to |
| 1301 // navigate. Just switch to the pending RFH now and go back to non | 1430 // navigate. Just switch to the pending RFH now and go back to non |
| 1302 // cross-navigating (Note that we don't care about on{before}unload | 1431 // cross-navigating (Note that we don't care about on{before}unload |
| 1303 // handlers if the current RFH isn't live.) | 1432 // handlers if the current RFH isn't live.) |
| 1304 CommitPending(); | 1433 CommitPending(); |
| 1305 return render_frame_host_.get(); | 1434 return render_frame_host_.get(); |
| 1306 } else { | 1435 } else { |
| 1307 NOTREACHED(); | 1436 NOTREACHED(); |
| 1308 return render_frame_host_.get(); | 1437 return render_frame_host_.get(); |
| 1309 } | 1438 } |
| 1310 } | 1439 } |
| 1311 // Otherwise, it's safe to treat this as a pending cross-site transition. | 1440 // Otherwise, it's safe to treat this as a pending cross-site transition. |
| 1312 | 1441 |
| 1313 // We need to wait until the beforeunload handler has run, unless we are | 1442 // We need to wait until the beforeunload handler has run, unless we are |
| 1314 // transferring an existing request (in which case it has already run). | 1443 // transferring an existing request (in which case it has already run). |
| 1315 // Suspend the new render view (i.e., don't let it send the cross-site | 1444 // Suspend the new render view (i.e., don't let it send the cross-site |
| 1316 // Navigate message) until we hear back from the old renderer's | 1445 // Navigate message) until we hear back from the old renderer's |
| 1317 // beforeunload handler. If the handler returns false, we'll have to | 1446 // beforeunload handler. If the handler returns false, we'll have to |
| 1318 // cancel the request. | 1447 // cancel the request. |
| 1319 DCHECK(!pending_render_frame_host_->render_view_host()-> | 1448 DCHECK(!pending_render_frame_host_->render_view_host()-> |
| 1320 are_navigations_suspended()); | 1449 are_navigations_suspended()); |
| 1321 bool is_transfer = | 1450 bool is_transfer = |
| 1322 entry.transferred_global_request_id() != GlobalRequestID(); | 1451 entry.transferred_global_request_id() != GlobalRequestID(); |
| 1323 if (is_transfer) { | 1452 if (is_transfer) { |
| 1453 LOG(ERROR) << "RFHM::UpdateStateForNavigate[" << this << "]:" | |
| 1454 << " is_transfer: " << pending_nav_params_->global_request_id.child_ id; | |
| 1324 // We don't need to stop the old renderer or run beforeunload/unload | 1455 // We don't need to stop the old renderer or run beforeunload/unload |
| 1325 // handlers, because those have already been done. | 1456 // handlers, because those have already been done. |
| 1326 DCHECK(pending_nav_params_->global_request_id == | 1457 DCHECK(pending_nav_params_->global_request_id == |
| 1327 entry.transferred_global_request_id()); | 1458 entry.transferred_global_request_id()); |
| 1328 } else { | 1459 } else { |
| 1460 LOG(ERROR) << "RFHM::UpdateStateForNavigate[" << this << "]:" | |
| 1461 << " !is_transfer: "; | |
| 1329 // Also make sure the old render view stops, in case a load is in | 1462 // Also make sure the old render view stops, in case a load is in |
| 1330 // progress. (We don't want to do this for transfers, since it will | 1463 // progress. (We don't want to do this for transfers, since it will |
| 1331 // interrupt the transfer with an unexpected DidStopLoading.) | 1464 // interrupt the transfer with an unexpected DidStopLoading.) |
| 1332 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( | 1465 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( |
| 1333 render_frame_host_->render_view_host()->GetRoutingID())); | 1466 render_frame_host_->render_view_host()->GetRoutingID())); |
| 1334 | 1467 |
| 1335 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( | 1468 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( |
| 1336 true, base::TimeTicks()); | 1469 true, base::TimeTicks()); |
| 1337 | 1470 |
| 1338 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site | 1471 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site |
| 1339 // request, so that ResourceDispatcherHost will know to tell us to run the | 1472 // request, so that ResourceDispatcherHost will know to tell us to run the |
| 1340 // old page's unload handler before it sends the response. | 1473 // old page's unload handler before it sends the response. |
| 1341 // TODO(creis): This needs to be on the RFH. | 1474 // TODO(creis): This needs to be on the RFH. |
| 1342 pending_render_frame_host_->render_view_host()-> | 1475 pending_render_frame_host_->render_view_host()-> |
| 1343 SetHasPendingCrossSiteRequest(true); | 1476 SetHasPendingCrossSiteRequest(true); |
| 1344 } | 1477 } |
| 1345 | 1478 |
| 1346 // We now have a pending RFH. | 1479 // We now have a pending RFH. |
| 1347 DCHECK(!cross_navigation_pending_); | 1480 DCHECK(!cross_navigation_pending_); |
| 1348 cross_navigation_pending_ = true; | 1481 cross_navigation_pending_ = true; |
| 1349 | 1482 |
| 1350 // Unless we are transferring an existing request, we should now | 1483 // Unless we are transferring an existing request, we should now |
| 1351 // tell the old render view to run its beforeunload handler, since it | 1484 // tell the old render view to run its beforeunload handler, since it |
| 1352 // doesn't otherwise know that the cross-site request is happening. This | 1485 // doesn't otherwise know that the cross-site request is happening. This |
| 1353 // will trigger a call to OnBeforeUnloadACK with the reply. | 1486 // will trigger a call to OnBeforeUnloadACK with the reply. |
| 1354 if (!is_transfer) | 1487 if (!is_transfer) |
| 1355 render_frame_host_->DispatchBeforeUnload(true); | 1488 render_frame_host_->DispatchBeforeUnload(true); |
| 1356 | 1489 |
| 1490 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" | |
| 1491 << " returning " << pending_render_frame_host_.get(); | |
| 1357 return pending_render_frame_host_.get(); | 1492 return pending_render_frame_host_.get(); |
| 1358 } | 1493 } |
| 1359 | 1494 |
| 1360 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 1495 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
| 1361 DCHECK(!cross_navigation_pending_); | 1496 DCHECK(!cross_navigation_pending_); |
| 1362 if (ShouldReuseWebUI(current_entry, &entry)) { | 1497 if (ShouldReuseWebUI(current_entry, &entry)) { |
| 1363 pending_web_ui_.reset(); | 1498 pending_web_ui_.reset(); |
| 1364 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); | 1499 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); |
| 1365 } else { | 1500 } else { |
| 1366 SetPendingWebUI(entry); | 1501 SetPendingWebUI(entry); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 // If the SiteInstance for the pending RFH is being used by others, don't | 1539 // If the SiteInstance for the pending RFH is being used by others, don't |
| 1405 // delete the RFH, just swap it out and it can be reused at a later point. | 1540 // delete the RFH, just swap it out and it can be reused at a later point. |
| 1406 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( | 1541 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( |
| 1407 pending_render_frame_host->GetSiteInstance()); | 1542 pending_render_frame_host->GetSiteInstance()); |
| 1408 if (site_instance->active_view_count() > 1) { | 1543 if (site_instance->active_view_count() > 1) { |
| 1409 // Any currently suspended navigations are no longer needed. | 1544 // Any currently suspended navigations are no longer needed. |
| 1410 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); | 1545 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); |
| 1411 | 1546 |
| 1412 RenderFrameProxyHost* proxy = | 1547 RenderFrameProxyHost* proxy = |
| 1413 new RenderFrameProxyHost(site_instance, frame_tree_node_); | 1548 new RenderFrameProxyHost(site_instance, frame_tree_node_); |
| 1414 proxy_hosts_[site_instance->GetId()] = proxy; | 1549 proxy_hosts_[site_instance->GetId()] = proxy; |
|
ncarter (slow)
2014/06/25 01:07:56
Is there some invariant that guarantees that a pro
| |
| 1415 pending_render_frame_host->SwapOut(proxy); | 1550 pending_render_frame_host->SwapOut(proxy); |
| 1416 proxy->TakeFrameHostOwnership(pending_render_frame_host.Pass()); | 1551 if (frame_tree_node_->IsMainFrame()) { |
| 1552 proxy->TakeFrameHostOwnership(pending_render_frame_host.Pass()); | |
| 1553 } | |
| 1554 proxy_hosts_[site_instance->GetId()] = proxy; | |
|
ncarter (slow)
2014/06/25 01:07:56
I'm fairly certain that the proxy is already in th
| |
| 1417 } else { | 1555 } else { |
| 1418 // We won't be coming back, so delete this one. | 1556 // We won't be coming back, so delete this one. |
| 1419 pending_render_frame_host.reset(); | 1557 pending_render_frame_host.reset(); |
| 1420 } | 1558 } |
| 1421 | 1559 |
| 1422 pending_web_ui_.reset(); | 1560 pending_web_ui_.reset(); |
| 1423 pending_and_current_web_ui_.reset(); | 1561 pending_and_current_web_ui_.reset(); |
| 1424 } | 1562 } |
| 1425 | 1563 |
| 1426 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( | 1564 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1447 | 1585 |
| 1448 return old_render_frame_host.Pass(); | 1586 return old_render_frame_host.Pass(); |
| 1449 } | 1587 } |
| 1450 | 1588 |
| 1451 bool RenderFrameHostManager::IsRVHOnSwappedOutList( | 1589 bool RenderFrameHostManager::IsRVHOnSwappedOutList( |
| 1452 RenderViewHostImpl* rvh) const { | 1590 RenderViewHostImpl* rvh) const { |
| 1453 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost( | 1591 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost( |
| 1454 rvh->GetSiteInstance()); | 1592 rvh->GetSiteInstance()); |
| 1455 if (!proxy) | 1593 if (!proxy) |
| 1456 return false; | 1594 return false; |
| 1595 // If there is a proxy without RFH, it is for a subframe in the SiteInstance | |
| 1596 // of |rvh|. Subframes should be ignored in this case. | |
| 1597 if (!proxy->render_frame_host()) | |
| 1598 return false; | |
| 1457 return IsOnSwappedOutList(proxy->render_frame_host()); | 1599 return IsOnSwappedOutList(proxy->render_frame_host()); |
| 1458 } | 1600 } |
| 1459 | 1601 |
| 1460 bool RenderFrameHostManager::IsOnSwappedOutList( | 1602 bool RenderFrameHostManager::IsOnSwappedOutList( |
| 1461 RenderFrameHostImpl* rfh) const { | 1603 RenderFrameHostImpl* rfh) const { |
| 1462 if (!rfh->GetSiteInstance()) | 1604 if (!rfh->GetSiteInstance()) |
| 1463 return false; | 1605 return false; |
| 1464 | 1606 |
| 1465 RenderFrameProxyHostMap::const_iterator iter = proxy_hosts_.find( | 1607 RenderFrameProxyHostMap::const_iterator iter = proxy_hosts_.find( |
| 1466 rfh->GetSiteInstance()->GetId()); | 1608 rfh->GetSiteInstance()->GetId()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1482 SiteInstance* instance) const { | 1624 SiteInstance* instance) const { |
| 1483 RenderFrameProxyHostMap::const_iterator iter = | 1625 RenderFrameProxyHostMap::const_iterator iter = |
| 1484 proxy_hosts_.find(instance->GetId()); | 1626 proxy_hosts_.find(instance->GetId()); |
| 1485 if (iter != proxy_hosts_.end()) | 1627 if (iter != proxy_hosts_.end()) |
| 1486 return iter->second; | 1628 return iter->second; |
| 1487 | 1629 |
| 1488 return NULL; | 1630 return NULL; |
| 1489 } | 1631 } |
| 1490 | 1632 |
| 1491 } // namespace content | 1633 } // namespace content |
| OLD | NEW |