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

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

Issue 1417953002: PlzNavigate: Add tests to check WebUI navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from clamy@ comments. Created 5 years, 1 month 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 // if needed when it no longer breaks OAuth popups (see 993 // if needed when it no longer breaks OAuth popups (see
994 // https://crbug.com/440266). 994 // https://crbug.com/440266).
995 bool is_main_frame = frame_tree_node_->IsMainFrame(); 995 bool is_main_frame = frame_tree_node_->IsMainFrame();
996 if (current_site_instance == dest_site_instance.get() || 996 if (current_site_instance == dest_site_instance.get() ||
997 (!request.browser_initiated() && is_main_frame) || 997 (!request.browser_initiated() && is_main_frame) ||
998 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && 998 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() &&
999 !current_site_instance->RequiresDedicatedProcess())) { 999 !current_site_instance->RequiresDedicatedProcess())) {
1000 // Reuse the current RFH if its SiteInstance matches the the navigation's 1000 // Reuse the current RFH if its SiteInstance matches the the navigation's
1001 // or if this is a subframe navigation. We only swap RFHs for subframes when 1001 // or if this is a subframe navigation. We only swap RFHs for subframes when
1002 // --site-per-process is enabled. 1002 // --site-per-process is enabled.
1003 CleanUpNavigation(); 1003
1004 if (speculative_render_frame_host_)
clamy 2015/10/22 15:37:10 I think you could add a comment here to explain th
carlosk 2015/10/22 16:23:48 Done.
1005 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
1006
1004 navigation_rfh = render_frame_host_.get(); 1007 navigation_rfh = render_frame_host_.get();
1005 1008
1006 // As SiteInstances are the same, make the RFH update its possible pending 1009 // As SiteInstances are the same, make the RFH update its possible pending
1007 // WebUI. 1010 // WebUI.
1008 render_frame_host_->UpdatePendingWebUI(request.common_params().url, 1011 render_frame_host_->UpdatePendingWebUI(request.common_params().url,
1009 request.bindings()); 1012 request.bindings());
1010 DCHECK(speculative_web_ui() == render_frame_host_->pending_web_ui()); 1013 DCHECK(speculative_web_ui() == render_frame_host_->pending_web_ui());
1011 1014
1012 // If a pending WebUI was set on the current RenderFrameHost (be it a new 1015 // If a pending WebUI was set on the current RenderFrameHost (be it a new
1013 // one or the reused current one) and the associated RenderFrame is alive, 1016 // one or the reused current one) and the associated RenderFrame is alive,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 } 1088 }
1086 } 1089 }
1087 1090
1088 return navigation_rfh; 1091 return navigation_rfh;
1089 } 1092 }
1090 1093
1091 // PlzNavigate 1094 // PlzNavigate
1092 void RenderFrameHostManager::CleanUpNavigation() { 1095 void RenderFrameHostManager::CleanUpNavigation() {
1093 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1096 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1094 switches::kEnableBrowserSideNavigation)); 1097 switches::kEnableBrowserSideNavigation));
1095 // TODO(carlosk): the discarding of the current RFH WebUI and the cleanup of
1096 // the speculative RFH should not always happen together.
1097 render_frame_host_->DiscardPendingWebUI(); 1098 render_frame_host_->DiscardPendingWebUI();
1098 if (speculative_render_frame_host_) 1099 if (speculative_render_frame_host_)
1099 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); 1100 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
1100 } 1101 }
1101 1102
1102 // PlzNavigate 1103 // PlzNavigate
1103 scoped_ptr<RenderFrameHostImpl> 1104 scoped_ptr<RenderFrameHostImpl>
1104 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { 1105 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() {
1105 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1106 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1106 switches::kEnableBrowserSideNavigation)); 1107 switches::kEnableBrowserSideNavigation));
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2578 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2578 if (!frame_tree_node_->opener()) 2579 if (!frame_tree_node_->opener())
2579 return MSG_ROUTING_NONE; 2580 return MSG_ROUTING_NONE;
2580 2581
2581 return frame_tree_node_->opener() 2582 return frame_tree_node_->opener()
2582 ->render_manager() 2583 ->render_manager()
2583 ->GetRoutingIdForSiteInstance(instance); 2584 ->GetRoutingIdForSiteInstance(instance);
2584 } 2585 }
2585 2586
2586 } // namespace content 2587 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698