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 // TODO(carlosk): begin tracking metrics fort renderer initiated navigations | |
776 // once the renderer correctly provides its request start time. | |
clamy
2015/01/27 12:35:04
I don't think we ever want to track renderer initi
carlosk
2015/01/27 17:12:03
Agreed and removed the comment.
I didn't realize
| |
777 navigation_data_.reset(); | |
carlosk
2015/01/26 19:54:01
Added a couple metrics-reset-points (here and belo
| |
775 } | 778 } |
776 DCHECK(navigation_request); | 779 DCHECK(navigation_request); |
777 | 780 |
778 // Update the referrer with the one received from the renderer. | 781 // Update the referrer with the one received from the renderer. |
779 navigation_request->common_params().referrer = common_params.referrer; | 782 navigation_request->common_params().referrer = common_params.referrer; |
780 | 783 |
781 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); | 784 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); |
782 | 785 |
783 info->first_party_for_cookies = | 786 info->first_party_for_cookies = |
784 frame_tree_node->IsMainFrame() | 787 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(), | 829 render_frame_host->CommitNavigation(response, body.Pass(), |
827 navigation_request->common_params(), | 830 navigation_request->common_params(), |
828 navigation_request->commit_params()); | 831 navigation_request->commit_params()); |
829 } | 832 } |
830 | 833 |
831 // PlzNavigate | 834 // PlzNavigate |
832 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { | 835 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { |
833 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 836 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
834 switches::kEnableBrowserSideNavigation)); | 837 switches::kEnableBrowserSideNavigation)); |
835 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 838 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
839 navigation_data_.reset(); | |
carlosk
2015/01/26 19:54:01
Also resetting when cancelling the navigation.
No
| |
836 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once | 840 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once |
837 // we properly cancel ongoing navigations. | 841 // we properly cancel ongoing navigations. |
838 frame_tree_node->render_manager()->CleanUpNavigation(); | 842 frame_tree_node->render_manager()->CleanUpNavigation(); |
839 } | 843 } |
840 | 844 |
841 // PlzNavigate | 845 // PlzNavigate |
842 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( | 846 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( |
843 FrameTreeNode* frame_tree_node) { | 847 FrameTreeNode* frame_tree_node) { |
844 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 848 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
845 } | 849 } |
846 | 850 |
847 bool NavigatorImpl::IsWaitingForBeforeUnloadACK( | 851 bool NavigatorImpl::IsWaitingForBeforeUnloadACK( |
848 FrameTreeNode* frame_tree_node) { | 852 FrameTreeNode* frame_tree_node) { |
849 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 853 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
850 switches::kEnableBrowserSideNavigation)); | 854 switches::kEnableBrowserSideNavigation)); |
851 NavigationRequest* request = | 855 NavigationRequest* request = |
852 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 856 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
853 if (!request) | 857 if (!request) |
854 return false; | 858 return false; |
855 return request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE; | 859 return request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE; |
856 } | 860 } |
857 | 861 |
858 void NavigatorImpl::LogResourceRequestTime( | 862 void NavigatorImpl::LogResourceRequestTime( |
859 base::TimeTicks timestamp, const GURL& url) { | 863 base::TimeTicks timestamp, const GURL& url) { |
864 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
865 switches::kEnableBrowserSideNavigation)); | |
carlosk
2015/01/26 19:54:01
Now this method is called only for non-PlzNavigate
clamy
2015/01/27 12:35:04
I think they are very similar and we should just h
carlosk
2015/01/27 17:12:03
I didn't think it would be so bad to have them sep
clamy
2015/01/28 13:44:21
Or you can just call LogResourceRequestTime with t
carlosk
2015/01/28 15:21:08
Done. Also added a TODO to rename it later.
| |
860 if (navigation_data_ && navigation_data_->url_ == url) { | 866 if (navigation_data_ && navigation_data_->url_ == url) { |
861 navigation_data_->url_job_start_time_ = timestamp; | 867 navigation_data_->url_job_start_time_ = timestamp; |
862 UMA_HISTOGRAM_TIMES( | 868 UMA_HISTOGRAM_TIMES( |
863 "Navigation.TimeToURLJobStart", | 869 "Navigation.TimeToURLJobStart", |
864 navigation_data_->url_job_start_time_ - navigation_data_->start_time_); | 870 navigation_data_->url_job_start_time_ - navigation_data_->start_time_); |
865 } | 871 } |
866 } | 872 } |
867 | 873 |
874 void NavigatorImpl::LogAboutToBeginNavigation(base::TimeTicks timestamp) { | |
875 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
876 switches::kEnableBrowserSideNavigation)); | |
877 if (navigation_data_) { | |
carlosk
2015/01/26 19:54:01
Note that we don't do URL checks here because they
clamy
2015/01/27 12:35:04
Acknowledged.
| |
878 navigation_data_->url_job_start_time_ = timestamp; | |
879 UMA_HISTOGRAM_TIMES( | |
880 "Navigation.TimeToURLJobStart", | |
881 navigation_data_->url_job_start_time_ - navigation_data_->start_time_); | |
882 } | |
883 } | |
884 | |
868 void NavigatorImpl::LogBeforeUnloadTime( | 885 void NavigatorImpl::LogBeforeUnloadTime( |
869 const base::TimeTicks& renderer_before_unload_start_time, | 886 const base::TimeTicks& renderer_before_unload_start_time, |
870 const base::TimeTicks& renderer_before_unload_end_time) { | 887 const base::TimeTicks& renderer_before_unload_end_time) { |
871 // Only stores the beforeunload delay if we're tracking a browser initiated | 888 // Only stores the beforeunload delay if we're tracking a browser initiated |
872 // navigation and it happened later than the navigation request. | 889 // navigation and it happened later than the navigation request. |
873 if (navigation_data_ && | 890 if (navigation_data_ && |
874 renderer_before_unload_start_time > navigation_data_->start_time_) { | 891 renderer_before_unload_start_time > navigation_data_->start_time_) { |
875 navigation_data_->before_unload_delay_ = | 892 navigation_data_->before_unload_delay_ = |
876 renderer_before_unload_end_time - renderer_before_unload_start_time; | 893 renderer_before_unload_end_time - renderer_before_unload_start_time; |
877 } | 894 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 998 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
982 time_to_commit); | 999 time_to_commit); |
983 UMA_HISTOGRAM_TIMES( | 1000 UMA_HISTOGRAM_TIMES( |
984 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 1001 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
985 time_to_network); | 1002 time_to_network); |
986 } | 1003 } |
987 navigation_data_.reset(); | 1004 navigation_data_.reset(); |
988 } | 1005 } |
989 | 1006 |
990 } // namespace content | 1007 } // namespace content |
OLD | NEW |