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

Unified Diff: chrome/browser/metrics/tab_usage_recorder.h

Issue 2335203003: Add metrics to keep track of the tab activate/deactivate cycle (Closed)
Patch Set: Moved the TabStripModelObserver change to another CL Created 4 years, 3 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/metrics/tab_usage_recorder.h
diff --git a/chrome/browser/metrics/tab_usage_recorder.h b/chrome/browser/metrics/tab_usage_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..fee2042b6d26f6d7317acb6acf3ebea0a1918c8f
--- /dev/null
+++ b/chrome/browser/metrics/tab_usage_recorder.h
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_
+#define CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/browser_tab_strip_tracker.h"
+#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+
+namespace metrics {
+
+// This class is used to record metrics about tab reactivation. Specifically,
+// it records the number of times a tab is deactivated and reactivated. The
+// ratio of both can be calculated for tabs with different properties (e.g. If
+// the tab is pinned to the tab strip) to see if they are correlated with higher
+// probability of tab reactivation.
+class TabUsageRecorder : public TabStripModelObserver {
+ public:
+ // Starts recording tab usage for all browsers.
+ static void Initialize();
+
+ // TabStripModelObserver:
+ void TabInsertedAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index,
+ bool foreground) override;
+ void TabClosingAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) override;
+ void ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) override;
+ void TabPinnedStateChanged(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) override;
+
+ private:
+ class WebContentsData;
+
+ TabUsageRecorder();
+ ~TabUsageRecorder() override;
+
+ BrowserTabStripTracker browser_tab_strip_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabUsageRecorder);
+};
+
+} // namespace metrics
+
+#endif // CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_

Powered by Google App Engine
This is Rietveld 408576698