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

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

Issue 1153193011: PlzNavigate: send Javascript urls synchronously to the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit test now that data urls are sent committed synchronously Created 5 years, 7 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 8219a3d79518bc95ca9ff998a620c0f149838a86..888a2b7e41ae0fa86ef664bc880bfa37254ab2e1 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -717,6 +717,11 @@ void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node,
render_frame_host->CommitNavigation(response, body.Pass(),
navigation_request->common_params(),
navigation_request->request_params());
+
+ // When navigating to a Javascript url, no commit is expected from the
+ // RenderFrameHost, therefore the NavigationRequest should be reset right now.
+ if (navigation_request->common_params().url.SchemeIs(url::kJavaScriptScheme))
+ frame_tree_node->ResetNavigationRequest(true);
}
// PlzNavigate
@@ -820,12 +825,19 @@ void NavigatorImpl::RequestNavigation(
navigation_type,
navigation_start, controller_);
frame_tree_node->SetNavigationRequest(navigation_request.Pass());
+ frame_tree_node->navigation_request()->SetWaitingForRendererResponse();
// 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();
- frame_tree_node->current_frame_host()->DispatchBeforeUnload(true);
+ // 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)) {
+ frame_tree_node->current_frame_host()->DispatchBeforeUnload(true);
+ } else {
+ BeginNavigation(frame_tree_node);
+ }
}
void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) {
« no previous file with comments | « content/browser/frame_host/navigation_request.cc ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698