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

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

Issue 1163303003: PlzNavigate: Create the speculative renderer earlier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 aff92459639e88b0a6b77752b4de2b3ae1ea43d8..7ee98057cf107da0bd196581ca2b4cf848e93255 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -600,8 +600,9 @@ void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE,
navigation_request->state());
+ // If the navigation is allowed to proceed, send the request to the IO thread.
if (proceed)
- BeginNavigation(frame_tree_node);
+ navigation_request->BeginNavigation();
else
CancelNavigation(frame_tree_node);
}
@@ -655,7 +656,7 @@ void NavigatorImpl::OnBeginNavigation(
navigation_data_.reset();
}
- BeginNavigation(frame_tree_node);
+ frame_tree_node->navigation_request()->BeginNavigation();
}
// PlzNavigate
@@ -803,42 +804,31 @@ void NavigatorImpl::RequestNavigation(
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
DCHECK(frame_tree_node);
+
+ // This value must be set here because SetNavigationRequest might change the
+ // renderer live/non-live status and change this result.
+ bool should_dispatch_beforeunload =
+ frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload();
FrameMsg_Navigate_Type::Value navigation_type =
GetNavigationType(controller_->GetBrowserContext(), entry, reload_type);
- scoped_ptr<NavigationRequest> navigation_request =
+ frame_tree_node->SetNavigationRequest(
NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry,
navigation_type,
- navigation_start, controller_);
- frame_tree_node->SetNavigationRequest(navigation_request.Pass());
- frame_tree_node->navigation_request()->SetWaitingForRendererResponse();
+ navigation_start, controller_));
+ NavigationRequest* navigation_request = frame_tree_node->navigation_request();
// 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. If the navigation is synchronous and same-site, then it can be sent
- // directly to the renderer (currently this is the case for navigations that
- // do not make network requests such as data urls or Javascript urls).
- if (NavigationRequest::ShouldMakeNetworkRequest(
- frame_tree_node->navigation_request()->common_params().url)) {
+ // is not needed NavigationRequest::BeginNavigation should get called. This is
+ // the case if the renderer is not live, this is a subframe navigation, or if
nasko 2015/06/12 17:22:22 The details of when running the beforeUnload handl
carlosk 2015/06/15 19:11:54 I'm assuming the same logic applies to the details
+ // the navigation is synchronous and same-site (such as for data URLs or
+ // Javascript URLs, when no network request is made).
+ if (should_dispatch_beforeunload &&
+ NavigationRequest::ShouldMakeNetworkRequest(
+ navigation_request->common_params().url)) {
+ navigation_request->SetWaitingForRendererResponse();
frame_tree_node->current_frame_host()->DispatchBeforeUnload(true);
} else {
- BeginNavigation(frame_tree_node);
- }
-}
-
-void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) {
- NavigationRequest* navigation_request = frame_tree_node->navigation_request();
-
- // A browser-initiated navigation could have been cancelled while it was
- // waiting for the BeforeUnload event to execute.
- if (!navigation_request)
- return;
-
- // Start the request.
- if (navigation_request->BeginNavigation()) {
- // If the request was sent to the IO thread, notify the
- // RenderFrameHostManager so it can speculatively create a RenderFrameHost
- // (and potentially a new renderer process) in parallel.
- frame_tree_node->render_manager()->BeginNavigation(*navigation_request);
+ navigation_request->BeginNavigation();
}
}

Powered by Google App Engine
This is Rietveld 408576698