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

Side by Side 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, 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 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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 new ViewMsg_EnableViewSourceMode( 710 new ViewMsg_EnableViewSourceMode(
711 render_frame_host->render_view_host()->GetRoutingID())); 711 render_frame_host->render_view_host()->GetRoutingID()));
712 } 712 }
713 713
714 CheckWebUIRendererDoesNotDisplayNormalURL( 714 CheckWebUIRendererDoesNotDisplayNormalURL(
715 render_frame_host, navigation_request->common_params().url); 715 render_frame_host, navigation_request->common_params().url);
716 716
717 render_frame_host->CommitNavigation(response, body.Pass(), 717 render_frame_host->CommitNavigation(response, body.Pass(),
718 navigation_request->common_params(), 718 navigation_request->common_params(),
719 navigation_request->request_params()); 719 navigation_request->request_params());
720
721 // When navigating to a Javascript url, no commit is expected from the
722 // RenderFrameHost, therefore the NavigationRequest should be reset right now.
723 if (navigation_request->common_params().url.SchemeIs(url::kJavaScriptScheme))
724 frame_tree_node->ResetNavigationRequest(true);
720 } 725 }
721 726
722 // PlzNavigate 727 // PlzNavigate
723 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, 728 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node,
724 bool has_stale_copy_in_cache, 729 bool has_stale_copy_in_cache,
725 int error_code) { 730 int error_code) {
726 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 731 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
727 switches::kEnableBrowserSideNavigation)); 732 switches::kEnableBrowserSideNavigation));
728 733
729 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 734 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 818 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
814 switches::kEnableBrowserSideNavigation)); 819 switches::kEnableBrowserSideNavigation));
815 DCHECK(frame_tree_node); 820 DCHECK(frame_tree_node);
816 FrameMsg_Navigate_Type::Value navigation_type = 821 FrameMsg_Navigate_Type::Value navigation_type =
817 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); 822 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type);
818 scoped_ptr<NavigationRequest> navigation_request = 823 scoped_ptr<NavigationRequest> navigation_request =
819 NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry, 824 NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry,
820 navigation_type, 825 navigation_type,
821 navigation_start, controller_); 826 navigation_start, controller_);
822 frame_tree_node->SetNavigationRequest(navigation_request.Pass()); 827 frame_tree_node->SetNavigationRequest(navigation_request.Pass());
828 frame_tree_node->navigation_request()->SetWaitingForRendererResponse();
823 829
824 // Have the current renderer execute its beforeUnload event if needed. If it 830 // Have the current renderer execute its beforeUnload event if needed. If it
825 // is not needed (eg. the renderer is not live), BeginNavigation should get 831 // is not needed (eg. the renderer is not live), BeginNavigation should get
826 // called. 832 // called. If the navigation is synchronous and same-site, then it can be sent
827 frame_tree_node->navigation_request()->SetWaitingForRendererResponse(); 833 // directly to the renderer (currently this is the case for navigations that
828 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); 834 // do not make network requests such as data urls or Javascript urls).
835 if (NavigationRequest::ShouldMakeNetworkRequest(
836 frame_tree_node->navigation_request()->common_params().url)) {
837 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true);
838 } else {
839 BeginNavigation(frame_tree_node);
840 }
829 } 841 }
830 842
831 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) { 843 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) {
832 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 844 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
833 845
834 // A browser-initiated navigation could have been cancelled while it was 846 // A browser-initiated navigation could have been cancelled while it was
835 // waiting for the BeforeUnload event to execute. 847 // waiting for the BeforeUnload event to execute.
836 if (!navigation_request) 848 if (!navigation_request)
837 return; 849 return;
838 850
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", 905 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted",
894 time_to_commit); 906 time_to_commit);
895 UMA_HISTOGRAM_TIMES( 907 UMA_HISTOGRAM_TIMES(
896 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", 908 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted",
897 time_to_network); 909 time_to_network);
898 } 910 }
899 navigation_data_.reset(); 911 navigation_data_.reset();
900 } 912 }
901 913
902 } // namespace content 914 } // namespace content
OLDNEW
« 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