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

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

Issue 475783002: PlzNavigate: add cancel navigation logic for uncommitted requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the actual calls to cancel the navigation request Created 6 years, 3 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 RenderFrameHostManager::~RenderFrameHostManager() { 100 RenderFrameHostManager::~RenderFrameHostManager() {
101 if (pending_render_frame_host_) 101 if (pending_render_frame_host_)
102 CancelPending(); 102 CancelPending();
103 103
104 // We should always have a current RenderFrameHost except in some tests. 104 // We should always have a current RenderFrameHost except in some tests.
105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); 105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>());
106 106
107 // Delete any swapped out RenderFrameHosts. 107 // Delete any swapped out RenderFrameHosts.
108 STLDeleteValues(&proxy_hosts_); 108 STLDeleteValues(&proxy_hosts_);
109
110 // PlzNavigate
111 // There is an active navigation request for this RFHM so it needs to be
112 // canceled.
113 if (CommandLine::ForCurrentProcess()->HasSwitch(
114 switches::kEnableBrowserSideNavigation)) {
115 if (navigation_request_.get())
116 navigation_request_->CancelNavigation();
117 }
118
109 } 119 }
110 120
111 void RenderFrameHostManager::Init(BrowserContext* browser_context, 121 void RenderFrameHostManager::Init(BrowserContext* browser_context,
112 SiteInstance* site_instance, 122 SiteInstance* site_instance,
113 int view_routing_id, 123 int view_routing_id,
114 int frame_routing_id) { 124 int frame_routing_id) {
115 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It 125 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It
116 // is important to immediately give this SiteInstance to a RenderViewHost so 126 // is important to immediately give this SiteInstance to a RenderViewHost so
117 // that the SiteInstance is ref counted. 127 // that the SiteInstance is ref counted.
118 if (!site_instance) 128 if (!site_instance)
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); 430 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess());
421 process->ResumeResponseDeferredAtStart(*response_started_id_); 431 process->ResumeResponseDeferredAtStart(*response_started_id_);
422 432
423 render_frame_host_->ClearPendingTransitionRequestData(); 433 render_frame_host_->ClearPendingTransitionRequestData();
424 434
425 response_started_id_.reset(); 435 response_started_id_.reset();
426 } 436 }
427 437
428 void RenderFrameHostManager::DidNavigateFrame( 438 void RenderFrameHostManager::DidNavigateFrame(
429 RenderFrameHostImpl* render_frame_host) { 439 RenderFrameHostImpl* render_frame_host) {
440 // PlzNavigate
441 // The navigation request has been committed so the browser process doesn't
442 // need to care about it anymore.
443 if (CommandLine::ForCurrentProcess()->HasSwitch(
444 switches::kEnableBrowserSideNavigation)) {
445 navigation_request_.reset();
(Do not use) nasko 2014/08/28 15:55:05 This seems a bit fragile to me. Once we tell the r
carlosk 2014/08/29 15:54:43 I think this was what was discussed between you Na
446 }
447
430 if (!cross_navigation_pending_) { 448 if (!cross_navigation_pending_) {
431 DCHECK(!pending_render_frame_host_); 449 DCHECK(!pending_render_frame_host_);
432 450
433 // We should only hear this from our current renderer. 451 // We should only hear this from our current renderer.
434 DCHECK_EQ(render_frame_host_, render_frame_host); 452 DCHECK_EQ(render_frame_host_, render_frame_host);
435 453
436 // 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.
437 if (pending_web_ui()) 455 if (pending_web_ui())
438 CommitPending(); 456 CommitPending();
439 return; 457 return;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 params.url : frame_tree_node_->frame_tree()->root()->current_url(); 591 params.url : frame_tree_node_->frame_tree()->root()->current_url();
574 info.is_main_frame = frame_tree_node_->IsMainFrame(); 592 info.is_main_frame = frame_tree_node_->IsMainFrame();
575 info.parent_is_main_frame = !frame_tree_node_->parent() ? 593 info.parent_is_main_frame = !frame_tree_node_->parent() ?
576 false : frame_tree_node_->parent()->IsMainFrame(); 594 false : frame_tree_node_->parent()->IsMainFrame();
577 info.is_showing = GetRenderWidgetHostView()->IsShowing(); 595 info.is_showing = GetRenderWidgetHostView()->IsShowing();
578 596
579 // TODO(clamy): Check if the current RFH should be initialized (in case it has 597 // TODO(clamy): Check if the current RFH should be initialized (in case it has
580 // crashed) not to display a sad tab while navigating. 598 // crashed) not to display a sad tab while navigating.
581 // TODO(clamy): Spawn a speculative renderer process if we do not have one to 599 // TODO(clamy): Spawn a speculative renderer process if we do not have one to
582 // use for the navigation. 600 // use for the navigation.
601
602 if (navigation_request_.get())
clamy 2014/08/28 12:17:01 Please add a comment explaining that if we have a
carlosk 2014/08/29 15:54:43 Done.
603 navigation_request_->CancelNavigation();
604
583 navigation_request_.reset(new NavigationRequest( 605 navigation_request_.reset(new NavigationRequest(
584 info, frame_tree_node_->frame_tree_node_id())); 606 info, frame_tree_node_->frame_tree_node_id()));
585 navigation_request_->BeginNavigation(params.request_body); 607 navigation_request_->BeginNavigation(params.request_body);
586 } 608 }
587 609
588 // PlzNavigate 610 // PlzNavigate
589 void RenderFrameHostManager::CommitNavigation( 611 void RenderFrameHostManager::CommitNavigation(
590 const NavigationBeforeCommitInfo& info) { 612 const NavigationBeforeCommitInfo& info) {
591 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 613 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
592 switches::kEnableBrowserSideNavigation)); 614 switches::kEnableBrowserSideNavigation));
615 DCHECK(navigation_request_.get());
616 // Ignores navigation commits if the request ID doesn't match the current
617 // active request.
618 if (navigation_request_->navigation_request_id() !=
619 info.navigation_request_id) {
620 return;
621 }
622
593 // Pick the right RenderFrameHost to commit the navigation. 623 // Pick the right RenderFrameHost to commit the navigation.
594 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 624 SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
595 // TODO(clamy): Replace the default values by the right ones. This may require 625 // TODO(clamy): Replace the default values by the right ones. This may require
596 // some storing in RequestNavigation. 626 // some storing in RequestNavigation.
597 SiteInstance* new_instance = GetSiteInstanceForNavigation( 627 SiteInstance* new_instance = GetSiteInstanceForNavigation(
598 info.navigation_url, 628 info.navigation_url,
599 NULL, 629 NULL,
600 navigation_request_->info().navigation_params.transition_type, 630 navigation_request_->info().navigation_params.transition_type,
601 false, 631 false,
602 false); 632 false);
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1688 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1659 SiteInstance* instance) { 1689 SiteInstance* instance) {
1660 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1690 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1661 if (iter != proxy_hosts_.end()) { 1691 if (iter != proxy_hosts_.end()) {
1662 delete iter->second; 1692 delete iter->second;
1663 proxy_hosts_.erase(iter); 1693 proxy_hosts_.erase(iter);
1664 } 1694 }
1665 } 1695 }
1666 1696
1667 } // namespace content 1697 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698