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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 // navigation may start in a renderer and commit in another one. | 765 // navigation may start in a renderer and commit in another one. |
766 // TODO(clamy): See if the navigation start time should be measured in the | 766 // TODO(clamy): See if the navigation start time should be measured in the |
767 // renderer and sent to the browser instead of being measured here. | 767 // renderer and sent to the browser instead of being measured here. |
768 scoped_ptr<NavigationRequest> scoped_request(new NavigationRequest( | 768 scoped_ptr<NavigationRequest> scoped_request(new NavigationRequest( |
769 frame_tree_node, common_params, | 769 frame_tree_node, common_params, |
770 CommitNavigationParams(PageState(), false, base::TimeTicks::Now()), | 770 CommitNavigationParams(PageState(), false, base::TimeTicks::Now()), |
771 nullptr)); | 771 nullptr)); |
772 navigation_request = scoped_request.get(); | 772 navigation_request = scoped_request.get(); |
773 navigation_request_map_.set( | 773 navigation_request_map_.set( |
774 frame_tree_node->frame_tree_node_id(), scoped_request.Pass()); | 774 frame_tree_node->frame_tree_node_id(), scoped_request.Pass()); |
775 navigation_data_.reset(); | |
davidben
2015/02/02 22:33:57
Does this also need an IsMainFrame guard?
carlosk
2015/02/03 11:00:04
No because here we actually want it to be reset. T
clamy
2015/02/03 12:13:54
I think we should have one for the case where the
carlosk
2015/02/03 12:48:34
You are both right indeed, sorry. Done.
| |
775 } | 776 } |
776 DCHECK(navigation_request); | 777 DCHECK(navigation_request); |
777 | 778 |
778 // Update the referrer with the one received from the renderer. | 779 // Update the referrer with the one received from the renderer. |
779 navigation_request->common_params().referrer = common_params.referrer; | 780 navigation_request->common_params().referrer = common_params.referrer; |
780 | 781 |
781 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); | 782 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); |
782 | 783 |
783 info->first_party_for_cookies = | 784 info->first_party_for_cookies = |
784 frame_tree_node->IsMainFrame() | 785 frame_tree_node->IsMainFrame() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 render_frame_host->CommitNavigation(response, body.Pass(), | 827 render_frame_host->CommitNavigation(response, body.Pass(), |
827 navigation_request->common_params(), | 828 navigation_request->common_params(), |
828 navigation_request->commit_params()); | 829 navigation_request->commit_params()); |
829 } | 830 } |
830 | 831 |
831 // PlzNavigate | 832 // PlzNavigate |
832 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { | 833 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { |
833 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 834 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
834 switches::kEnableBrowserSideNavigation)); | 835 switches::kEnableBrowserSideNavigation)); |
835 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 836 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
837 if (frame_tree_node->IsMainFrame()) | |
838 navigation_data_.reset(); | |
836 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once | 839 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once |
837 // we properly cancel ongoing navigations. | 840 // we properly cancel ongoing navigations. |
838 frame_tree_node->render_manager()->CleanUpNavigation(); | 841 frame_tree_node->render_manager()->CleanUpNavigation(); |
839 } | 842 } |
840 | 843 |
841 // PlzNavigate | 844 // PlzNavigate |
842 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( | 845 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( |
843 FrameTreeNode* frame_tree_node) { | 846 FrameTreeNode* frame_tree_node) { |
844 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 847 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
845 } | 848 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
937 void NavigatorImpl::RecordNavigationMetrics( | 940 void NavigatorImpl::RecordNavigationMetrics( |
938 const LoadCommittedDetails& details, | 941 const LoadCommittedDetails& details, |
939 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 942 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
940 SiteInstance* site_instance) { | 943 SiteInstance* site_instance) { |
941 DCHECK(site_instance->HasProcess()); | 944 DCHECK(site_instance->HasProcess()); |
942 | 945 |
943 if (!details.is_in_page) | 946 if (!details.is_in_page) |
944 RecordAction(base::UserMetricsAction("FrameLoad")); | 947 RecordAction(base::UserMetricsAction("FrameLoad")); |
945 | 948 |
946 if (!details.is_main_frame || !navigation_data_ || | 949 if (!details.is_main_frame || !navigation_data_ || |
950 navigation_data_->url_job_start_time_.is_null() || | |
carlosk
2015/01/30 14:01:47
I realized that if for some reason NavigatorImpl::
| |
947 navigation_data_->url_ != params.original_request_url) { | 951 navigation_data_->url_ != params.original_request_url) { |
948 return; | 952 return; |
949 } | 953 } |
950 | 954 |
951 base::TimeDelta time_to_commit = | 955 base::TimeDelta time_to_commit = |
952 base::TimeTicks::Now() - navigation_data_->start_time_; | 956 base::TimeTicks::Now() - navigation_data_->start_time_; |
953 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit); | 957 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit); |
954 | 958 |
955 time_to_commit -= navigation_data_->before_unload_delay_; | 959 time_to_commit -= navigation_data_->before_unload_delay_; |
956 base::TimeDelta time_to_network = navigation_data_->url_job_start_time_ - | 960 base::TimeDelta time_to_network = navigation_data_->url_job_start_time_ - |
(...skipping 24 matching lines...) Expand all Loading... | |
981 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 985 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
982 time_to_commit); | 986 time_to_commit); |
983 UMA_HISTOGRAM_TIMES( | 987 UMA_HISTOGRAM_TIMES( |
984 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 988 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
985 time_to_network); | 989 time_to_network); |
986 } | 990 } |
987 navigation_data_.reset(); | 991 navigation_data_.reset(); |
988 } | 992 } |
989 | 993 |
990 } // namespace content | 994 } // namespace content |
OLD | NEW |