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

Unified Diff: content/browser/frame_host/navigator_impl.cc

Issue 1092973002: Revert of PlzNavigate: move ownership of the NavigationRequest to the FrameTreeNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 3097a542bd49760ac3a8314f52d54bf62a3ad0f3..fd59de25c324c7bebe2e9f46604ce172cc70f7e5 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -367,7 +367,8 @@
// need to care about it anymore.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- render_frame_host->frame_tree_node()->ResetNavigationRequest(true);
+ navigation_request_map_.erase(
+ render_frame_host->frame_tree_node()->frame_tree_node_id());
}
FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params);
@@ -614,7 +615,8 @@
switches::kEnableBrowserSideNavigation));
DCHECK(frame_tree_node);
- NavigationRequest* navigation_request = frame_tree_node->navigation_request();
+ NavigationRequest* navigation_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
// The NavigationRequest may have been canceled while the renderer was
// executing the BeforeUnload event.
@@ -642,7 +644,7 @@
DCHECK(frame_tree_node);
NavigationRequest* ongoing_navigation_request =
- frame_tree_node->navigation_request();
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
// The renderer-initiated navigation request is ignored iff a) there is an
// ongoing request b) which is browser or user-initiated and c) the renderer
@@ -655,13 +657,17 @@
}
// In all other cases the current navigation, if any, is canceled and a new
- // NavigationRequest is created for the node.
+ // NavigationRequest is created and stored in the map.
+ if (ongoing_navigation_request)
+ CancelNavigation(frame_tree_node);
+
scoped_ptr<NavigationRequest> navigation_request =
NavigationRequest::CreateRendererInitiated(
frame_tree_node, common_params, begin_params, body,
controller_->GetLastCommittedEntryIndex(),
controller_->GetEntryCount());
- frame_tree_node->SetNavigationRequest(navigation_request.Pass());
+ navigation_request_map_.set(
+ frame_tree_node->frame_tree_node_id(), navigation_request.Pass());
if (frame_tree_node->IsMainFrame())
navigation_data_.reset();
@@ -676,7 +682,8 @@
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
- NavigationRequest* navigation_request = frame_tree_node->navigation_request();
+ NavigationRequest* navigation_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
DCHECK(navigation_request);
DCHECK(response ||
!NavigationRequest::ShouldMakeNetworkRequest(
@@ -722,7 +729,8 @@
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
- NavigationRequest* navigation_request = frame_tree_node->navigation_request();
+ NavigationRequest* navigation_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
DCHECK(navigation_request);
// Select an appropriate renderer to show the error page.
@@ -741,16 +749,26 @@
void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) {
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
- frame_tree_node->ResetNavigationRequest(false);
+ navigation_request_map_.erase(frame_tree_node->frame_tree_node_id());
if (frame_tree_node->IsMainFrame())
navigation_data_.reset();
+ // TODO(carlosk): move this cleanup into the NavigationRequest destructor once
+ // we properly cancel ongoing navigations.
+ frame_tree_node->render_manager()->CleanUpNavigation();
+}
+
+// PlzNavigate
+NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting(
+ FrameTreeNode* frame_tree_node) {
+ return navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
}
bool NavigatorImpl::IsWaitingForBeforeUnloadACK(
FrameTreeNode* frame_tree_node) {
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
- NavigationRequest* request = frame_tree_node->navigation_request();
+ NavigationRequest* request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
if (!request)
return false;
return request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE;
@@ -803,23 +821,36 @@
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
DCHECK(frame_tree_node);
+ int64 frame_tree_node_id = frame_tree_node->frame_tree_node_id();
FrameMsg_Navigate_Type::Value navigation_type =
GetNavigationType(controller_->GetBrowserContext(), entry, reload_type);
scoped_ptr<NavigationRequest> navigation_request =
NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry,
navigation_type,
navigation_start, controller_);
- frame_tree_node->SetNavigationRequest(navigation_request.Pass());
+ // TODO(clamy): Check if navigations are blocked and if so store the
+ // parameters.
+
+ // If there is an ongoing request, cancel and replace it.
+ NavigationRequest* ongoing_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
+ if (ongoing_request)
+ CancelNavigation(frame_tree_node);
+
+ navigation_request_map_.set(frame_tree_node_id, navigation_request.Pass());
// Have the current renderer execute its beforeUnload event if needed. If it
// is not needed (eg. the renderer is not live), BeginNavigation should get
// called.
- frame_tree_node->navigation_request()->SetWaitingForRendererResponse();
+ NavigationRequest* request_to_send =
+ navigation_request_map_.get(frame_tree_node_id);
+ request_to_send->SetWaitingForRendererResponse();
frame_tree_node->current_frame_host()->DispatchBeforeUnload(true);
}
void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) {
- NavigationRequest* navigation_request = frame_tree_node->navigation_request();
+ NavigationRequest* navigation_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
// A browser-initiated navigation could have been cancelled while it was
// waiting for the BeforeUnload event to execute.
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698