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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 } else { | 170 } else { |
171 params->redirects.clear(); | 171 params->redirects.clear(); |
172 } | 172 } |
173 | 173 |
174 params->can_load_local_resources = entry.GetCanLoadLocalResources(); | 174 params->can_load_local_resources = entry.GetCanLoadLocalResources(); |
175 params->frame_to_navigate = entry.GetFrameToNavigate(); | 175 params->frame_to_navigate = entry.GetFrameToNavigate(); |
176 } | 176 } |
177 | 177 |
178 } // namespace | 178 } // namespace |
179 | 179 |
180 NavigatorImpl::NavigationMetricsData::NavigationMetricsData( | |
181 base::TimeTicks start_time, GURL url) : start_time_(start_time), url_(url) { | |
nasko
2014/10/08 17:10:42
Please use clang-format/git cl format or keep to t
carlosk
2014/10/09 16:53:45
Done! I had tried to run those tools before but on
| |
182 } | |
183 | |
184 void NavigatorImpl::NavigationMetricsData::Reset() { | |
185 start_time_ = base::TimeTicks(); | |
186 url_ = GURL(); | |
187 url_job_start_time_ = base::TimeTicks(); | |
188 before_unload_delay_ = base::TimeDelta(); | |
189 } | |
190 | |
191 bool NavigatorImpl::NavigationMetricsData::IsTracking() { | |
192 return ! start_time_.is_null(); | |
nasko
2014/10/08 17:10:42
nit: no need for space between ! and start_time_.
carlosk
2014/10/09 16:53:45
Done.
| |
193 } | |
194 | |
180 | 195 |
181 NavigatorImpl::NavigatorImpl( | 196 NavigatorImpl::NavigatorImpl( |
182 NavigationControllerImpl* navigation_controller, | 197 NavigationControllerImpl* navigation_controller, |
183 NavigatorDelegate* delegate) | 198 NavigatorDelegate* delegate) |
184 : controller_(navigation_controller), | 199 : controller_(navigation_controller), |
185 delegate_(delegate) { | 200 delegate_(delegate) { |
186 } | 201 } |
187 | 202 |
188 NavigatorImpl::~NavigatorImpl() {} | 203 NavigatorImpl::~NavigatorImpl() {} |
189 | 204 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 367 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
353 // capture the time needed for the RenderFrameHost initialization. | 368 // capture the time needed for the RenderFrameHost initialization. |
354 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 369 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
355 | 370 |
356 RenderFrameHostManager* manager = | 371 RenderFrameHostManager* manager = |
357 render_frame_host->frame_tree_node()->render_manager(); | 372 render_frame_host->frame_tree_node()->render_manager(); |
358 | 373 |
359 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 374 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
360 if (CommandLine::ForCurrentProcess()->HasSwitch( | 375 if (CommandLine::ForCurrentProcess()->HasSwitch( |
361 switches::kEnableBrowserSideNavigation)) { | 376 switches::kEnableBrowserSideNavigation)) { |
362 navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL()); | 377 navigation_data = NavigatorImpl::NavigationMetricsData( |
378 navigation_start, entry.GetURL()); | |
363 return RequestNavigation(render_frame_host->frame_tree_node(), | 379 return RequestNavigation(render_frame_host->frame_tree_node(), |
364 entry, | 380 entry, |
365 reload_type, | 381 reload_type, |
366 navigation_start); | 382 navigation_start); |
367 } | 383 } |
368 | 384 |
369 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); | 385 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); |
370 if (!dest_render_frame_host) | 386 if (!dest_render_frame_host) |
371 return false; // Unable to create the desired RenderFrameHost. | 387 return false; // Unable to create the desired RenderFrameHost. |
372 | 388 |
(...skipping 18 matching lines...) Expand all Loading... | |
391 | 407 |
392 // Navigate in the desired RenderFrameHost. | 408 // Navigate in the desired RenderFrameHost. |
393 // We can skip this step in the rare case that this is a transfer navigation | 409 // We can skip this step in the rare case that this is a transfer navigation |
394 // which began in the chosen RenderFrameHost, since the request has already | 410 // which began in the chosen RenderFrameHost, since the request has already |
395 // been issued. In that case, simply resume the response. | 411 // been issued. In that case, simply resume the response. |
396 bool is_transfer_to_same = | 412 bool is_transfer_to_same = |
397 navigate_params.transferred_request_child_id != -1 && | 413 navigate_params.transferred_request_child_id != -1 && |
398 navigate_params.transferred_request_child_id == | 414 navigate_params.transferred_request_child_id == |
399 dest_render_frame_host->GetProcess()->GetID(); | 415 dest_render_frame_host->GetProcess()->GetID(); |
400 if (!is_transfer_to_same) { | 416 if (!is_transfer_to_same) { |
401 navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL()); | 417 navigation_data = NavigatorImpl::NavigationMetricsData( |
418 navigation_start, entry.GetURL()); | |
402 dest_render_frame_host->Navigate(navigate_params); | 419 dest_render_frame_host->Navigate(navigate_params); |
403 } else { | 420 } else { |
404 // No need to navigate again. Just resume the deferred request. | 421 // No need to navigate again. Just resume the deferred request. |
405 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 422 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
406 GlobalRequestID(navigate_params.transferred_request_child_id, | 423 GlobalRequestID(navigate_params.transferred_request_child_id, |
407 navigate_params.transferred_request_request_id)); | 424 navigate_params.transferred_request_request_id)); |
408 } | 425 } |
409 | 426 |
410 // Make sure no code called via RFH::Navigate clears the pending entry. | 427 // Make sure no code called via RFH::Navigate clears the pending entry. |
411 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 428 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 if (!did_navigate) | 581 if (!did_navigate) |
565 return; // No navigation happened. | 582 return; // No navigation happened. |
566 | 583 |
567 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen | 584 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen |
568 // for the appropriate notification (best) or you can add it to | 585 // for the appropriate notification (best) or you can add it to |
569 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if | 586 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if |
570 // necessary, please). | 587 // necessary, please). |
571 | 588 |
572 // TODO(carlosk): Move this out when PlzNavigate implementation properly calls | 589 // TODO(carlosk): Move this out when PlzNavigate implementation properly calls |
573 // the observer methods. | 590 // the observer methods. |
574 if (details.is_main_frame && | 591 RecordNavigationMetrics(details, params, site_instance); |
575 navigation_start_time_and_url.a.ToInternalValue() != 0 | |
576 && navigation_start_time_and_url.b == params.original_request_url) { | |
577 base::TimeDelta time_to_commit = | |
578 base::TimeTicks::Now() - navigation_start_time_and_url.a; | |
579 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit); | |
580 navigation_start_time_and_url = MakeTuple(base::TimeTicks(), GURL()); | |
581 } | |
582 | 592 |
583 // Run post-commit tasks. | 593 // Run post-commit tasks. |
584 if (delegate_) { | 594 if (delegate_) { |
585 if (details.is_main_frame) | 595 if (details.is_main_frame) |
586 delegate_->DidNavigateMainFramePostCommit(details, params); | 596 delegate_->DidNavigateMainFramePostCommit(details, params); |
587 | 597 |
588 delegate_->DidNavigateAnyFramePostCommit( | 598 delegate_->DidNavigateAnyFramePostCommit( |
589 render_frame_host, details, params); | 599 render_frame_host, details, params); |
590 } | 600 } |
591 } | 601 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 NavigationRequest* navigation_request = | 778 NavigationRequest* navigation_request = |
769 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 779 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
770 if (!navigation_request) | 780 if (!navigation_request) |
771 return; | 781 return; |
772 navigation_request->CancelNavigation(); | 782 navigation_request->CancelNavigation(); |
773 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 783 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
774 } | 784 } |
775 | 785 |
776 void NavigatorImpl::LogResourceRequestTime( | 786 void NavigatorImpl::LogResourceRequestTime( |
777 base::TimeTicks timestamp, const GURL& url) { | 787 base::TimeTicks timestamp, const GURL& url) { |
778 if (navigation_start_time_and_url.a.ToInternalValue() != 0 | 788 if (navigation_data.IsTracking() && navigation_data.url_ == url) { |
779 && navigation_start_time_and_url.b == url) { | 789 navigation_data.url_job_start_time_ = timestamp; |
780 base::TimeDelta time_to_network = | |
781 timestamp - navigation_start_time_and_url.a; | |
782 UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStart", time_to_network); | |
783 } | 790 } |
784 } | 791 } |
785 | 792 |
793 void NavigatorImpl::LogBeforeUnloadTime( | |
794 const base::TimeTicks& renderer_before_unload_start_time, | |
795 const base::TimeTicks& renderer_before_unload_end_time) { | |
796 // Only stores the beforeunload delay if we're tracking the navigation and it | |
797 // happened later than the navigation request | |
798 if (navigation_data.IsTracking() | |
799 && renderer_before_unload_start_time > navigation_data.start_time_) { | |
800 navigation_data.before_unload_delay_ = | |
801 renderer_before_unload_end_time - renderer_before_unload_start_time; | |
802 } | |
803 } | |
804 | |
786 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( | 805 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( |
787 RenderFrameHostImpl* render_frame_host, | 806 RenderFrameHostImpl* render_frame_host, |
788 const GURL& url) { | 807 const GURL& url) { |
789 int enabled_bindings = | 808 int enabled_bindings = |
790 render_frame_host->render_view_host()->GetEnabledBindings(); | 809 render_frame_host->render_view_host()->GetEnabledBindings(); |
791 bool is_allowed_in_web_ui_renderer = | 810 bool is_allowed_in_web_ui_renderer = |
792 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 811 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
793 controller_->GetBrowserContext(), url); | 812 controller_->GetBrowserContext(), url); |
794 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 813 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
795 !is_allowed_in_web_ui_renderer) { | 814 !is_allowed_in_web_ui_renderer) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 } | 861 } |
843 | 862 |
844 // The navigation request is sent directly to the IO thread. | 863 // The navigation request is sent directly to the IO thread. |
845 OnBeginNavigation( | 864 OnBeginNavigation( |
846 frame_tree_node, | 865 frame_tree_node, |
847 MakeDefaultBeginNavigation(request_params, navigation_type), | 866 MakeDefaultBeginNavigation(request_params, navigation_type), |
848 navigation_request_map_.get(frame_tree_node_id)->common_params()); | 867 navigation_request_map_.get(frame_tree_node_id)->common_params()); |
849 return true; | 868 return true; |
850 } | 869 } |
851 | 870 |
871 void NavigatorImpl::RecordNavigationMetrics( | |
872 const LoadCommittedDetails& details, | |
873 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | |
874 SiteInstance* site_instance) { | |
875 DCHECK(site_instance->HasProcess()); | |
876 if (details.is_main_frame | |
877 && navigation_data.IsTracking() | |
878 && navigation_data.url_ == params.original_request_url) { | |
879 | |
880 base::TimeDelta time_to_commit = | |
881 base::TimeTicks::Now() - navigation_data.start_time_; | |
882 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommitRaw", time_to_commit); | |
883 base::TimeDelta time_to_network = | |
884 navigation_data.url_job_start_time_ - navigation_data.start_time_; | |
885 UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStartRaw", time_to_network); | |
886 | |
887 time_to_commit -= navigation_data.before_unload_delay_; | |
888 time_to_network -= navigation_data.before_unload_delay_; | |
889 bool spawned_new_process = | |
890 site_instance->GetProcess()->GetInitTime() > navigation_data.start_time_; | |
nasko
2014/10/08 17:10:42
Is there a different way to judge this? I'd rather
carlosk
2014/10/09 16:53:45
What I'm trying to separate here are navigations t
clamy
2014/10/09 19:02:32
I think you could easily distinguish between the c
carlosk
2014/10/10 10:00:03
As we're trying to eliminate the bi-modality this
clamy
2014/10/10 19:59:12
No that I know of. In any case, I am not sure we w
carlosk
2014/10/13 14:05:50
Indeed we might not be able to eliminate the bi/mu
| |
891 if (spawned_new_process) { | |
892 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommitNewRenderer", time_to_commit); | |
893 UMA_HISTOGRAM_TIMES( | |
894 "Navigation.TimeToURLJobStartNewRenderer", time_to_network); | |
895 } else { | |
896 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommitOldRenderer", time_to_commit); | |
897 UMA_HISTOGRAM_TIMES( | |
898 "Navigation.TimeToURLJobStartOldRenderer", time_to_network); | |
899 } | |
900 | |
901 navigation_data.Reset(); | |
902 } | |
903 } | |
904 | |
852 } // namespace content | 905 } // namespace content |
OLD | NEW |