Add histograms that track how long it takes to open the new tab page.
This doesn't time all loads of the new tab page, just new foreground
tabs using ctrl+t or the plus button. This includes the time it takes
to create the tab contents and logs the time until JS has started
executing, domcontentloaded, and onload.
Note: onload doesn't mean the page is done loading. We have "NewTabUI load" for that.
BUG=23120
Review URL: http://codereview.chromium.org/242107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27918 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index c59ea35..6fd8877 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1170,6 +1170,24 @@
active_entry->page_id() == page_id);
}
+void TabContents::LogNewTabTime(const std::string& event_name) {
+ // Not all new tab pages get timed. In those cases, we don't have a
+ // new_tab_start_time_.
+ if (new_tab_start_time_.is_null())
+ return;
+
+ base::TimeDelta duration = base::TimeTicks::Now() - new_tab_start_time_;
+ if (event_name == "NewTab.ScriptStart") {
+ UMA_HISTOGRAM_TIMES("NewTab.ScriptStart", duration);
+ } else if (event_name == "NewTab.DOMContentLoaded") {
+ UMA_HISTOGRAM_TIMES("NewTab.DOMContentLoaded", duration);
+ } else if (event_name == "NewTab.Onload") {
+ UMA_HISTOGRAM_TIMES("NewTab.Onload", duration);
+ // The new tab page has finished loading; reset it.
+ new_tab_start_time_ = base::TimeTicks();
+ }
+}
+
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void TabContents::SetIsLoading(bool is_loading,