Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 2236753002: OOPIF: Reinitialize a dead subframe correctly for same-site navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@crash-RenderView-pending-rfh
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (!dest_render_frame_host->IsRenderFrameLive()) { 231 if (!dest_render_frame_host->IsRenderFrameLive()) {
232 // Instruct the destination render frame host to set up a Mojo connection 232 // Instruct the destination render frame host to set up a Mojo connection
233 // with the new render frame if necessary. Note that this call needs to 233 // with the new render frame if necessary. Note that this call needs to
234 // occur before initializing the RenderView; the flow of creating the 234 // occur before initializing the RenderView; the flow of creating the
235 // RenderView can cause browser-side code to execute that expects the this 235 // RenderView can cause browser-side code to execute that expects the this
236 // RFH's shell::InterfaceRegistry to be initialized (e.g., if the site is a 236 // RFH's shell::InterfaceRegistry to be initialized (e.g., if the site is a
237 // WebUI site that is handled via Mojo, then Mojo WebUI code in //chrome 237 // WebUI site that is handled via Mojo, then Mojo WebUI code in //chrome
238 // will add an interface to this RFH's InterfaceRegistry). 238 // will add an interface to this RFH's InterfaceRegistry).
239 dest_render_frame_host->SetUpMojoIfNeeded(); 239 dest_render_frame_host->SetUpMojoIfNeeded();
240 240
241 // Recreate the opener chain. 241 if (!ReinitializeRenderFrame(dest_render_frame_host))
242 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(),
243 frame_tree_node_);
244 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr))
245 return nullptr; 242 return nullptr;
246 243
247 if (GetNavigatingWebUI()) { 244 if (GetNavigatingWebUI()) {
248 // A new RenderView was created and there is a navigating WebUI which 245 // A new RenderView was created and there is a navigating WebUI which
249 // never interacted with it. So notify the WebUI using RenderViewCreated. 246 // never interacted with it. So notify the WebUI using RenderViewCreated.
250 GetNavigatingWebUI()->RenderViewCreated( 247 GetNavigatingWebUI()->RenderViewCreated(
251 dest_render_frame_host->render_view_host()); 248 dest_render_frame_host->render_view_host());
252 } 249 }
253 250
254 // Now that we've created a new renderer, be sure to hide it if it isn't 251 // Now that we've created a new renderer, be sure to hide it if it isn't
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 861 }
865 } 862 }
866 } 863 }
867 DCHECK(navigation_rfh && 864 DCHECK(navigation_rfh &&
868 (navigation_rfh == render_frame_host_.get() || 865 (navigation_rfh == render_frame_host_.get() ||
869 navigation_rfh == speculative_render_frame_host_.get())); 866 navigation_rfh == speculative_render_frame_host_.get()));
870 867
871 // If the RenderFrame that needs to navigate is not live (its process was just 868 // If the RenderFrame that needs to navigate is not live (its process was just
872 // created or has crashed), initialize it. 869 // created or has crashed), initialize it.
873 if (!navigation_rfh->IsRenderFrameLive()) { 870 if (!navigation_rfh->IsRenderFrameLive()) {
874 // Recreate the opener chain. 871 if (!ReinitializeRenderFrame(navigation_rfh))
875 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_);
876 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr))
877 return nullptr; 872 return nullptr;
873
878 notify_webui_of_rv_creation = true; 874 notify_webui_of_rv_creation = true;
879 875
880 if (navigation_rfh == render_frame_host_.get()) { 876 if (navigation_rfh == render_frame_host_.get()) {
881 // TODO(nasko): This is a very ugly hack. The Chrome extensions process 877 // TODO(nasko): This is a very ugly hack. The Chrome extensions process
882 // manager still uses NotificationService and expects to see a 878 // manager still uses NotificationService and expects to see a
883 // RenderViewHost changed notification after WebContents and 879 // RenderViewHost changed notification after WebContents and
884 // RenderFrameHostManager are completely initialized. This should be 880 // RenderFrameHostManager are completely initialized. This should be
885 // removed once the process manager moves away from NotificationService. 881 // removed once the process manager moves away from NotificationService.
886 // See https://crbug.com/462682. 882 // See https://crbug.com/462682.
887 delegate_->NotifyMainFrameSwappedFromRenderManager( 883 delegate_->NotifyMainFrameSwappedFromRenderManager(
888 nullptr, render_frame_host_->render_view_host()); 884 nullptr, render_frame_host_->render_view_host());
889 } 885 }
890 DCHECK(navigation_rfh->IsRenderFrameLive());
891 } 886 }
892 887
893 // If a WebUI was created in a speculative RenderFrameHost or a new RenderView 888 // If a WebUI was created in a speculative RenderFrameHost or a new RenderView
894 // was created then the WebUI never interacted with the RenderView. Notify 889 // was created then the WebUI never interacted with the RenderView. Notify
895 // using RenderViewCreated. 890 // using RenderViewCreated.
896 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) 891 if (notify_webui_of_rv_creation && GetNavigatingWebUI())
897 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); 892 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host());
898 893
899 return navigation_rfh; 894 return navigation_rfh;
900 } 895 }
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 2014
2020 base::debug::DumpWithoutCrashing(); 2015 base::debug::DumpWithoutCrashing();
2021 } 2016 }
2022 } 2017 }
2023 2018
2024 return delegate_->CreateRenderFrameForRenderManager( 2019 return delegate_->CreateRenderFrameForRenderManager(
2025 render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id, 2020 render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id,
2026 previous_sibling_routing_id); 2021 previous_sibling_routing_id);
2027 } 2022 }
2028 2023
2024 bool RenderFrameHostManager::ReinitializeRenderFrame(
2025 RenderFrameHostImpl* render_frame_host) {
2026 // This should be used only when the RenderFrame is not live.
2027 DCHECK(!render_frame_host->IsRenderFrameLive());
2028
2029 // Recreate the opener chain.
2030 CreateOpenerProxies(render_frame_host->GetSiteInstance(), frame_tree_node_);
2031
2032 // Main frames need both the RenderView and RenderFrame reinitialized, so
2033 // use InitRenderView. For cross-process subframes, InitRenderView won't
2034 // recreate the RenderFrame, so use InitRenderFrame instead. Note that for
2035 // subframe RenderFrameHosts, the swapped out RenderView in their
2036 // SiteInstance will be recreated as part of CreateOpenerProxies above.
2037 if (!frame_tree_node_->parent()) {
2038 DCHECK(!GetRenderFrameProxyHost(render_frame_host->GetSiteInstance()));
2039 if (!InitRenderView(render_frame_host->render_view_host(), nullptr))
alexmos 2016/08/11 01:07:31 I was thinking whether passing a nullptr proxy is
Charlie Reis 2016/08/11 18:50:29 Acknowledged.
2040 return false;
2041 } else {
2042 if (!InitRenderFrame(render_frame_host))
2043 return false;
2044
2045 // When a subframe renderer dies, its RenderWidgetHostView is cleared in
2046 // its CrossProcessFrameConnector, so we need to restore it now that it
2047 // is re-initialized.
2048 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent();
2049 if (proxy_to_parent)
2050 GetProxyToParent()->SetChildRWHView(render_frame_host->GetView());
alexmos 2016/08/11 01:07:31 Normally, this is done as part of CommitPending().
Charlie Reis 2016/08/11 18:50:29 Acknowledged.
2051 }
2052
2053 DCHECK(render_frame_host->IsRenderFrameLive());
2054 return true;
2055 }
2056
2029 int RenderFrameHostManager::GetRoutingIdForSiteInstance( 2057 int RenderFrameHostManager::GetRoutingIdForSiteInstance(
2030 SiteInstance* site_instance) { 2058 SiteInstance* site_instance) {
2031 if (render_frame_host_->GetSiteInstance() == site_instance) 2059 if (render_frame_host_->GetSiteInstance() == site_instance)
2032 return render_frame_host_->GetRoutingID(); 2060 return render_frame_host_->GetRoutingID();
2033 2061
2034 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); 2062 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance);
2035 if (proxy) 2063 if (proxy)
2036 return proxy->GetRoutingID(); 2064 return proxy->GetRoutingID();
2037 2065
2038 return MSG_ROUTING_NONE; 2066 return MSG_ROUTING_NONE;
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 resolved_url)) { 2652 resolved_url)) {
2625 DCHECK(!dest_instance || 2653 DCHECK(!dest_instance ||
2626 dest_instance == render_frame_host_->GetSiteInstance()); 2654 dest_instance == render_frame_host_->GetSiteInstance());
2627 return false; 2655 return false;
2628 } 2656 }
2629 2657
2630 return true; 2658 return true;
2631 } 2659 }
2632 2660
2633 } // namespace content 2661 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698