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

Unified Diff: content/browser/frame_host/navigator_impl.cc

Issue 633083002: Changes PlzNavitate histograms to try and simplify their multi-modal characteristic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR comments, renamed histograms using suffixes, other minor changes. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 611103dbb4117984b351435db8018b3ef62ddf10..29974e7d678557a5a3c832b981e5cee44f84bfb3 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -179,12 +179,45 @@ void MakeNavigateParams(const NavigationEntryImpl& entry,
} // namespace
+class NavigatorImpl::NavigationMetricsData {
clamy 2014/10/09 19:02:32 I think this should be a struct. If you keep it a
carlosk 2014/10/10 10:00:04 Done.
+ public:
+ NavigationMetricsData() {}
+ ~NavigationMetricsData() {}
+
+ void Reset();
+ void Set(base::TimeTicks start_time, GURL url);
clamy 2014/10/09 19:02:32 I would remove those methods and use the scoped_pt
carlosk 2014/10/10 10:00:04 Done! Much better indeed!
+ bool IsTracking();
+
+ base::TimeTicks start_time_;
+ GURL url_;
+ base::TimeTicks url_job_start_time_;
+ base::TimeDelta before_unload_delay_;
+};
+
+void NavigatorImpl::NavigationMetricsData::Reset() {
+ start_time_ = base::TimeTicks();
+ url_ = GURL();
+ url_job_start_time_ = base::TimeTicks();
+ before_unload_delay_ = base::TimeDelta();
+}
+
+void NavigatorImpl::NavigationMetricsData::Set(base::TimeTicks start_time,
+ GURL url) {
+ start_time_ = start_time;
+ url_ = url;
+ url_job_start_time_ = base::TimeTicks();
+ before_unload_delay_ = base::TimeDelta();
+}
+
+bool NavigatorImpl::NavigationMetricsData::IsTracking() {
+ return !start_time_.is_null();
+}
-NavigatorImpl::NavigatorImpl(
- NavigationControllerImpl* navigation_controller,
- NavigatorDelegate* delegate)
+NavigatorImpl::NavigatorImpl(NavigationControllerImpl* navigation_controller,
+ NavigatorDelegate* delegate)
: controller_(navigation_controller),
- delegate_(delegate) {
+ delegate_(delegate),
+ navigation_data_(new NavigationMetricsData()) {
}
NavigatorImpl::~NavigatorImpl() {}
@@ -361,7 +394,7 @@ bool NavigatorImpl::NavigateToEntry(
// PlzNavigate: the RenderFrameHosts are no longer asked to navigate.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL());
+ navigation_data_->Set(navigation_start, entry.GetURL());
clamy 2014/10/09 19:02:32 I would rather use an explicit reset on the scoped
carlosk 2014/10/10 10:00:04 Done.
return RequestNavigation(render_frame_host->frame_tree_node(),
entry,
reload_type,
@@ -400,7 +433,7 @@ bool NavigatorImpl::NavigateToEntry(
navigate_params.transferred_request_child_id ==
dest_render_frame_host->GetProcess()->GetID();
if (!is_transfer_to_same) {
- navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL());
+ navigation_data_->Set(navigation_start, entry.GetURL());
dest_render_frame_host->Navigate(navigate_params);
} else {
// No need to navigate again. Just resume the deferred request.
@@ -573,14 +606,7 @@ void NavigatorImpl::DidNavigate(
// TODO(carlosk): Move this out when PlzNavigate implementation properly calls
// the observer methods.
- if (details.is_main_frame &&
- navigation_start_time_and_url.a.ToInternalValue() != 0
- && navigation_start_time_and_url.b == params.original_request_url) {
- base::TimeDelta time_to_commit =
- base::TimeTicks::Now() - navigation_start_time_and_url.a;
- UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit);
- navigation_start_time_and_url = MakeTuple(base::TimeTicks(), GURL());
- }
+ RecordNavigationMetrics(details, params, site_instance);
// Run post-commit tasks.
if (delegate_) {
@@ -773,11 +799,23 @@ void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) {
void NavigatorImpl::LogResourceRequestTime(
base::TimeTicks timestamp, const GURL& url) {
- if (navigation_start_time_and_url.a.ToInternalValue() != 0
- && navigation_start_time_and_url.b == url) {
- base::TimeDelta time_to_network =
- timestamp - navigation_start_time_and_url.a;
- UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStart", time_to_network);
+ if (navigation_data_->IsTracking() && navigation_data_->url_ == url) {
+ navigation_data_->url_job_start_time_ = timestamp;
+ UMA_HISTOGRAM_TIMES(
+ "Navigation.TimeToURLJobStart",
+ navigation_data_->url_job_start_time_ - navigation_data_->start_time_);
+ }
+}
+
+void NavigatorImpl::LogBeforeUnloadTime(
+ const base::TimeTicks& renderer_before_unload_start_time,
+ const base::TimeTicks& renderer_before_unload_end_time) {
+ // Only stores the beforeunload delay if we're tracking the navigation and it
+ // happened later than the navigation request
+ if (navigation_data_->IsTracking() &&
+ renderer_before_unload_start_time > navigation_data_->start_time_) {
+ navigation_data_->before_unload_delay_ =
+ renderer_before_unload_end_time - renderer_before_unload_start_time;
}
}
@@ -842,4 +880,43 @@ bool NavigatorImpl::RequestNavigation(
return true;
}
+void NavigatorImpl::RecordNavigationMetrics(
+ const LoadCommittedDetails& details,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
+ SiteInstance* site_instance) {
+ DCHECK(site_instance->HasProcess());
+ if (details.is_main_frame && navigation_data_->IsTracking() &&
+ navigation_data_->url_ == params.original_request_url) {
+ base::TimeDelta time_to_commit =
+ base::TimeTicks::Now() - navigation_data_->start_time_;
+ UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit);
+
+ time_to_commit -= navigation_data_->before_unload_delay_;
+ base::TimeDelta time_to_network = navigation_data_->url_job_start_time_ -
+ navigation_data_->start_time_ -
+ navigation_data_->before_unload_delay_;
+ RenderProcessHostImpl* process_host =
+ static_cast<RenderProcessHostImpl*>(site_instance->GetProcess());
+ bool spawned_new_process =
+ process_host->GetInitTime() > navigation_data_->start_time_;
+ if (spawned_new_process) {
+ UMA_HISTOGRAM_TIMES(
+ "Navigation.TimeToCommit_NewRenderer_BeforeUnloadDiscounted",
+ time_to_commit);
+ UMA_HISTOGRAM_TIMES(
+ "Navigation.TimeToURLJobStart_NewRenderer_BeforeUnloadDiscounted",
+ time_to_network);
+ } else {
+ UMA_HISTOGRAM_TIMES(
+ "Navigation.TimeToCommit_OldRenderer_BeforeUnloadDiscounted",
+ time_to_commit);
+ UMA_HISTOGRAM_TIMES(
+ "Navigation.TimeToURLJobStart_OldRenderer_BeforeUnloadDiscounted",
+ time_to_network);
+ }
+
+ navigation_data_->Reset();
clamy 2014/10/09 19:02:32 I would reset the scoped ptr explicitly (navigatio
carlosk 2014/10/10 10:00:04 Done.
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698