OLD | NEW |
---|---|
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
696 else | 696 else |
697 CancelNavigation(frame_tree_node); | 697 CancelNavigation(frame_tree_node); |
698 } | 698 } |
699 | 699 |
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( |
Charlie Reis
2015/02/17 23:48:29
Let's put a comment at the top of this function sa
carlosk
2015/02/18 15:28:25
I thought it was better to actually rename the met
Charlie Reis
2015/02/19 00:58:00
No, I actually think the old OnBeginNavigation nam
carlosk
2015/02/19 10:45:18
I reverted the rename and added the comment.
But
Charlie Reis
2015/02/19 18:42:12
Sure, I'm happy to explain my reasoning:
Names ar
carlosk
2015/02/20 09:57:10
Acknowledged. Thanks.
| |
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 |
713 // current one. | 713 // The renderer navigation request is ignored iff a) there is an ongoing |
Charlie Reis
2015/02/17 23:48:29
nit: Please keep the term "renderer-initiated navi
carlosk
2015/02/18 15:28:25
Done.
| |
714 // request b) which is browser or user-initiated and c) the renderer request | |
715 // is not user-initiated. | |
716 if (ongoing_navigation_request && | |
717 (ongoing_navigation_request->browser_initiated() || | |
718 ongoing_navigation_request->begin_params().has_user_gesture) && | |
719 !begin_params.has_user_gesture) { | |
720 return; | |
721 } | |
722 | |
723 // In all other cases the current navigation, if any, is canceled and a new | |
724 // NavigationRequest is created and stored in the map. | |
Charlie Reis
2015/02/17 23:48:29
Can you mention where it gets canceled?
(I don't
clamy
2015/02/18 12:45:33
This is done upon destruction of the old Navigatio
carlosk
2015/02/18 15:28:25
I changed the comment to clarify that.
Charlie Reis
2015/02/19 00:58:00
Acknowledged.
| |
714 scoped_ptr<NavigationRequest> navigation_request = | 725 scoped_ptr<NavigationRequest> navigation_request = |
715 NavigationRequest::CreateRendererInitiated( | 726 NavigationRequest::CreateRendererInitiated( |
716 frame_tree_node, common_params, begin_params, body); | 727 frame_tree_node, common_params, begin_params, body); |
717 navigation_request_map_.set( | 728 navigation_request_map_.set( |
718 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); | 729 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); |
719 | 730 |
720 if (frame_tree_node->IsMainFrame()) | 731 if (frame_tree_node->IsMainFrame()) |
721 navigation_data_.reset(); | 732 navigation_data_.reset(); |
722 | 733 |
723 BeginNavigation(frame_tree_node); | 734 BeginNavigation(frame_tree_node); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
917 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 928 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
918 time_to_commit); | 929 time_to_commit); |
919 UMA_HISTOGRAM_TIMES( | 930 UMA_HISTOGRAM_TIMES( |
920 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 931 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
921 time_to_network); | 932 time_to_network); |
922 } | 933 } |
923 navigation_data_.reset(); | 934 navigation_data_.reset(); |
924 } | 935 } |
925 | 936 |
926 } // namespace content | 937 } // namespace content |
OLD | NEW |