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

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

Issue 789643005: PlzNavigate: make content unit tests work with browser side navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cancel-navigations
Patch Set: Added a static method to create NavigationRequests Created 5 years, 11 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 <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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // in progress. Sanity check this for http://crbug.com/276333. 274 // in progress. Sanity check this for http://crbug.com/276333.
275 CHECK(pending_render_frame_host_); 275 CHECK(pending_render_frame_host_);
276 276
277 // Unload handlers run in the background, so we should never get an 277 // Unload handlers run in the background, so we should never get an
278 // unresponsiveness warning for them. 278 // unresponsiveness warning for them.
279 CHECK(!render_frame_host_->IsWaitingForUnloadACK()); 279 CHECK(!render_frame_host_->IsWaitingForUnloadACK());
280 280
281 // If the tab becomes unresponsive during beforeunload while doing a 281 // If the tab becomes unresponsive during beforeunload while doing a
282 // cross-site navigation, proceed with the navigation. (This assumes that 282 // cross-site navigation, proceed with the navigation. (This assumes that
283 // the pending RenderFrameHost is still responsive.) 283 // the pending RenderFrameHost is still responsive.)
284 if (render_frame_host_->is_waiting_for_beforeunload_ack()) { 284 if (render_frame_host_->IsWaitingForBeforeUnloadACK()) {
285 // Haven't gotten around to starting the request, because we're still 285 // Haven't gotten around to starting the request, because we're still
286 // waiting for the beforeunload handler to finish. We'll pretend that it 286 // waiting for the beforeunload handler to finish. We'll pretend that it
287 // did finish, to let the navigation proceed. Note that there's a danger 287 // did finish, to let the navigation proceed. Note that there's a danger
288 // that the beforeunload handler will later finish and possibly return 288 // that the beforeunload handler will later finish and possibly return
289 // false (meaning the navigation should not proceed), but we'll ignore it 289 // false (meaning the navigation should not proceed), but we'll ignore it
290 // in this case because it took too long. 290 // in this case because it took too long.
291 if (pending_render_frame_host_->are_navigations_suspended()) { 291 if (pending_render_frame_host_->are_navigations_suspended()) {
292 pending_render_frame_host_->SetNavigationsSuspended( 292 pending_render_frame_host_->SetNavigationsSuspended(
293 false, base::TimeTicks::Now()); 293 false, base::TimeTicks::Now());
294 } 294 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 453
454 // Even when there is no pending RVH, there may be a pending Web UI. 454 // Even when there is no pending RVH, there may be a pending Web UI.
455 if (pending_web_ui()) 455 if (pending_web_ui())
456 CommitPending(); 456 CommitPending();
457 return; 457 return;
458 } 458 }
459 459
460 if (render_frame_host == pending_render_frame_host_) { 460 if (render_frame_host == pending_render_frame_host_) {
461 // The pending cross-site navigation completed, so show the renderer. 461 // The pending cross-site navigation completed, so show the renderer.
462 CommitPending(); 462 CommitPending();
463 cross_navigation_pending_ = false;
464 } else if (render_frame_host == render_frame_host_) { 463 } else if (render_frame_host == render_frame_host_) {
465 if (was_caused_by_user_gesture) { 464 if (was_caused_by_user_gesture) {
466 // A navigation in the original page has taken place. Cancel the pending 465 // A navigation in the original page has taken place. Cancel the pending
467 // one. Only do it for user gesture originated navigations to prevent 466 // one. Only do it for user gesture originated navigations to prevent
468 // page doing any shenanigans to prevent user from navigating. 467 // page doing any shenanigans to prevent user from navigating.
469 // See https://code.google.com/p/chromium/issues/detail?id=75195 468 // See https://code.google.com/p/chromium/issues/detail?id=75195
470 CancelPending(); 469 CancelPending();
471 cross_navigation_pending_ = false; 470 cross_navigation_pending_ = false;
472 } 471 }
473 } else { 472 } else {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 if (!navigation_rfh->IsRenderFrameLive()) { 729 if (!navigation_rfh->IsRenderFrameLive()) {
731 // Recreate the opener chain. 730 // Recreate the opener chain.
732 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( 731 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager(
733 navigation_rfh->GetSiteInstance()); 732 navigation_rfh->GetSiteInstance());
734 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id, 733 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id,
735 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) { 734 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) {
736 return nullptr; 735 return nullptr;
737 } 736 }
738 } 737 }
739 738
739 cross_navigation_pending_ = navigation_rfh != render_frame_host_.get();
nasko 2015/01/21 17:21:33 nit: If cross_navigation_pending_ is not used for
clamy 2015/01/21 19:39:41 Yes, but it is checked by a certain number of test
nasko 2015/01/21 19:47:06 Then the comment that it isn't used in PlzNavigate
740 return navigation_rfh; 740 return navigation_rfh;
741 } 741 }
742 742
743 // PlzNavigate 743 // PlzNavigate
744 void RenderFrameHostManager::CleanUpNavigation() { 744 void RenderFrameHostManager::CleanUpNavigation() {
745 if (speculative_render_frame_host_) 745 if (speculative_render_frame_host_)
746 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); 746 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
747 } 747 }
748 748
749 // PlzNavigate 749 // PlzNavigate
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 proxy_hosts_.find(site_instance->GetId()); 1454 proxy_hosts_.find(site_instance->GetId());
1455 if (iter != proxy_hosts_.end()) 1455 if (iter != proxy_hosts_.end())
1456 return iter->second->GetRoutingID(); 1456 return iter->second->GetRoutingID();
1457 1457
1458 return MSG_ROUTING_NONE; 1458 return MSG_ROUTING_NONE;
1459 } 1459 }
1460 1460
1461 void RenderFrameHostManager::CommitPending() { 1461 void RenderFrameHostManager::CommitPending() {
1462 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", 1462 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending",
1463 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 1463 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
1464 cross_navigation_pending_ = false;
nasko 2015/01/21 17:21:33 nit: I'd move this down to where we actually swap
clamy 2015/01/21 19:39:41 Done.
1464 bool browser_side_navigation = 1465 bool browser_side_navigation =
1465 base::CommandLine::ForCurrentProcess()->HasSwitch( 1466 base::CommandLine::ForCurrentProcess()->HasSwitch(
1466 switches::kEnableBrowserSideNavigation); 1467 switches::kEnableBrowserSideNavigation);
1467 // First check whether we're going to want to focus the location bar after 1468 // First check whether we're going to want to focus the location bar after
1468 // this commit. We do this now because the navigation hasn't formally 1469 // this commit. We do this now because the navigation hasn't formally
1469 // committed yet, so if we've already cleared |pending_web_ui_| the call chain 1470 // committed yet, so if we've already cleared |pending_web_ui_| the call chain
1470 // this triggers won't be able to figure out what's going on. 1471 // this triggers won't be able to figure out what's going on.
1471 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); 1472 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault();
1472 1473
1473 if (!browser_side_navigation) { 1474 if (!browser_side_navigation) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1869 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1869 SiteInstance* instance) { 1870 SiteInstance* instance) {
1870 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1871 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1871 if (iter != proxy_hosts_.end()) { 1872 if (iter != proxy_hosts_.end()) {
1872 delete iter->second; 1873 delete iter->second;
1873 proxy_hosts_.erase(iter); 1874 proxy_hosts_.erase(iter);
1874 } 1875 }
1875 } 1876 }
1876 1877
1877 } // namespace content 1878 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698