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

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

Issue 914223002: PlzNavigate: Updated navigation cancel policy for renderer-initiated requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some fixes and a new test added. Created 5 years, 10 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // PlzNavigate 700 // PlzNavigate
701 void NavigatorImpl::OnBeginNavigation( 701 void NavigatorImpl::OnBeginNavigation(
702 FrameTreeNode* frame_tree_node, 702 FrameTreeNode* frame_tree_node,
703 const CommonNavigationParams& common_params, 703 const CommonNavigationParams& common_params,
704 const BeginNavigationParams& begin_params, 704 const BeginNavigationParams& begin_params,
705 scoped_refptr<ResourceRequestBody> body) { 705 scoped_refptr<ResourceRequestBody> body) {
706 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 706 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
707 switches::kEnableBrowserSideNavigation)); 707 switches::kEnableBrowserSideNavigation));
708 DCHECK(frame_tree_node); 708 DCHECK(frame_tree_node);
709 709
710 // This is a renderer-initiated navigation, so generate a new 710 NavigationRequest* ongoing_navigation_request =
711 // NavigationRequest and store it in the map. 711 navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
712 // TODO(clamy): Renderer-initiated navigations should not always cancel the 712 if (ongoing_navigation_request &&
713 // current one. 713 (ongoing_navigation_request->browser_initiated() ||
714 ongoing_navigation_request->begin_params().has_user_gesture) &&
715 !begin_params.has_user_gesture) {
716 // The renderer navigation request is canceled iff a) there is an ongoing
717 // request b) which is user-initiated and c) the renderer request is not
718 // user-initiated.
719 return;
720 }
721
722 // In all other cases the current navigation, if any, is canceled and a new
723 // NavigationRequest is created and storeed in the map.
clamy 2015/02/12 18:08:06 nit: s/storeed/stored
carlosk 2015/02/13 13:44:29 Done.
714 scoped_ptr<NavigationRequest> navigation_request = 724 scoped_ptr<NavigationRequest> navigation_request =
715 NavigationRequest::CreateRendererInitiated( 725 NavigationRequest::CreateRendererInitiated(
716 frame_tree_node, common_params, begin_params, body); 726 frame_tree_node, common_params, begin_params, body);
717 navigation_request_map_.set( 727 navigation_request_map_.set(
718 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); 728 frame_tree_node->frame_tree_node_id(), navigation_request.Pass());
719 729
720 if (frame_tree_node->IsMainFrame()) 730 if (frame_tree_node->IsMainFrame())
721 navigation_data_.reset(); 731 navigation_data_.reset();
722 732
723 BeginNavigation(frame_tree_node); 733 BeginNavigation(frame_tree_node);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", 927 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted",
918 time_to_commit); 928 time_to_commit);
919 UMA_HISTOGRAM_TIMES( 929 UMA_HISTOGRAM_TIMES(
920 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", 930 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted",
921 time_to_network); 931 time_to_network);
922 } 932 }
923 navigation_data_.reset(); 933 navigation_data_.reset();
924 } 934 }
925 935
926 } // namespace content 936 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698