OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ |
6 #define CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ | 6 #define CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/metrics/tab_reactivation_tracker.h" | 9 #include "chrome/browser/metrics/tab_reactivation_tracker.h" |
10 #include "chrome/browser/ui/browser_tab_strip_tracker.h" | 10 #include "chrome/browser/ui/browser_tab_strip_tracker.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
12 | 12 |
13 namespace metrics { | 13 namespace metrics { |
14 | 14 |
15 // This class is used to record metrics about tab reactivation. Specifically, | 15 // This class is used to record metrics about tab reactivation. Specifically, |
16 // it records a histogram value everytime a tab is deactivated or reactivated. | 16 // it records a histogram value everytime a tab is deactivated or reactivated. |
17 // The ratio of both can be calculated for tabs with different properties (e.g. | 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 | 18 // If the tab is pinned to the tab strip) to see if they are correlated with |
19 // higher probability of tab reactivation. | 19 // higher probability of tab reactivation. |
20 class TabUsageRecorder : public TabReactivationTracker::Delegate, | 20 class TabUsageRecorder : public TabReactivationTracker::Delegate, |
21 public TabStripModelObserver { | 21 public TabStripModelObserver { |
22 public: | 22 public: |
23 // Needs to be public for DEFINE_WEB_CONTENTS_USER_DATA_KEY. | 23 // Needs to be public for DEFINE_WEB_CONTENTS_USER_DATA_KEY. |
24 class WebContentsData; | 24 class WebContentsData; |
25 | 25 |
26 // Starts recording tab usage for all browsers. | 26 // Starts recording tab usage for all browsers. |
27 static void Initialize(); | 27 static void InitializeIfNeeded(); |
28 | 28 |
29 // TabReactivationTracker::Delegate: | 29 // TabReactivationTracker::Delegate: |
30 void OnTabDeactivated(content::WebContents* contents) override; | 30 void OnTabDeactivated(content::WebContents* contents) override; |
31 void OnTabReactivated(content::WebContents* contents) override; | 31 void OnTabReactivated(content::WebContents* contents) override; |
32 | 32 |
33 // TabStripModelObserver: | 33 // TabStripModelObserver: |
34 void TabInsertedAt(TabStripModel* tab_strip_model, | 34 void TabInsertedAt(TabStripModel* tab_strip_model, |
35 content::WebContents* contents, | 35 content::WebContents* contents, |
36 int index, | 36 int index, |
37 bool foreground) override; | 37 bool foreground) override; |
(...skipping 11 matching lines...) Expand all Loading... |
49 | 49 |
50 TabReactivationTracker tab_reactivation_tracker_; | 50 TabReactivationTracker tab_reactivation_tracker_; |
51 BrowserTabStripTracker browser_tab_strip_tracker_; | 51 BrowserTabStripTracker browser_tab_strip_tracker_; |
52 | 52 |
53 DISALLOW_COPY_AND_ASSIGN(TabUsageRecorder); | 53 DISALLOW_COPY_AND_ASSIGN(TabUsageRecorder); |
54 }; | 54 }; |
55 | 55 |
56 } // namespace metrics | 56 } // namespace metrics |
57 | 57 |
58 #endif // CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ | 58 #endif // CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_H_ |
OLD | NEW |