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

Unified Diff: chrome/browser/ui/tab_contents/core_tab_helper.cc

Issue 17151010: Move histograms and supporting code that don't belong in content out. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix Created 7 years, 6 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: chrome/browser/ui/tab_contents/core_tab_helper.cc
===================================================================
--- chrome/browser/ui/tab_contents/core_tab_helper.cc (revision 207139)
+++ chrome/browser/ui/tab_contents/core_tab_helper.cc (working copy)
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
+#include "base/metrics/histogram.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -84,6 +85,26 @@
return string16();
}
+void CoreTabHelper::OnCloseStarted() {
+ if (close_start_time_.is_null())
+ close_start_time_ = base::TimeTicks::Now();
+}
+
+void CoreTabHelper::OnCloseCanceled() {
+ close_start_time_ = base::TimeTicks();
+ before_unload_end_time_ = base::TimeTicks();
+ unload_detached_start_time_ = base::TimeTicks();
+}
+
+void CoreTabHelper::OnUnloadStarted() {
+ before_unload_end_time_ = base::TimeTicks::Now();
+}
+
+void CoreTabHelper::OnUnloadDetachedStarted() {
+ if (unload_detached_start_time_.is_null())
+ unload_detached_start_time_ = base::TimeTicks::Now();
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebContentsObserver overrides
@@ -91,3 +112,30 @@
WebCacheManager::GetInstance()->ObserveActivity(
web_contents()->GetRenderProcessHost()->GetID());
}
+
+void CoreTabHelper::WebContentsDestroyed(WebContents* web_contents) {
+ // OnCloseStarted isn't called in unit tests.
+ if (!close_start_time_.is_null()) {
+ base::TimeTicks now = base::TimeTicks::Now();
+ base::TimeDelta close_time = now - close_start_time_;
+ UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
+
+ base::TimeTicks unload_start_time = close_start_time_;
+ base::TimeTicks unload_end_time = now;
+ if (!before_unload_end_time_.is_null())
+ unload_start_time = before_unload_end_time_;
+ if (!unload_detached_start_time_.is_null())
+ unload_end_time = unload_detached_start_time_;
+ base::TimeDelta unload_time = unload_end_time - unload_start_time;
+ UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
+
+ }
+}
+
+void CoreTabHelper::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
+ before_unload_end_time_ = proceed_time;
+}
+
+void CoreTabHelper::BeforeUnloadDialogCancelled() {
+ OnCloseCanceled();
+}

Powered by Google App Engine
This is Rietveld 408576698