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

Side by Side Diff: chrome/browser/metrics/tab_usage_recorder.h

Issue 2335203003: Add metrics to keep track of the tab activate/deactivate cycle (Closed)
Patch Set: Tab discarding resistant 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_
6 #define CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_
7
8 #include "base/macros.h"
9 #include "chrome/browser/metrics/tab_reactivation_tracker.h"
10 #include "chrome/browser/ui/browser_tab_strip_tracker.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
12
13 namespace metrics {
14
15 // This class is used to record metrics about tab reactivation. Specifically,
16 // it records an histogram value everytime a tab is deactivated or reactivated.
Georges Khalil 2016/09/22 18:38:38 nit: s/an/a
Patrick Monette 2016/09/22 20:18:52 Done.
17 // The ratio of both can be calculated for tabs with different properties (e.g.
18 // If the tab is pinned to the tab strip) to see if they are correlated with
19 // higher probability of tab reactivation.
20 class TabUsageRecorder : public TabReactivationTracker::Delegate,
21 public TabStripModelObserver {
22 public:
23 // Starts recording tab usage for all browsers.
24 static void Initialize();
25
26 // TabReactivationTracker::Delegate:
27 void OnTabDeactivated(content::WebContents* contents) override;
28 void OnTabReactivated(content::WebContents* contents) override;
29
30 // TabStripModelObserver:
31 void TabInsertedAt(TabStripModel* tab_strip_model,
32 content::WebContents* contents,
33 int index,
34 bool foreground) override;
35 void TabPinnedStateChanged(TabStripModel* tab_strip_model,
36 content::WebContents* contents,
37 int index) override;
38
39 private:
40 class WebContentsData;
41
42 TabUsageRecorder();
43 ~TabUsageRecorder() override;
44
45 // Returns the WebContentsData associated with |contents|, creating one if it
46 // doesn't exist.
47 WebContentsData* GetWebContentsData(content::WebContents* contents);
48
49 TabReactivationTracker tab_reactivation_tracker_;
50 BrowserTabStripTracker browser_tab_strip_tracker_;
51
52 DISALLOW_COPY_AND_ASSIGN(TabUsageRecorder);
53 };
54
55 } // namespace metrics
56
57 #endif // CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698