|
5 | 5 | #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.h"
|
6 | 6 |
|
7 | 7 | #import <algorithm>
|
| 8 | +#import <memory> |
8 | 9 |
|
9 | 10 | #import "base/check_op.h"
|
10 | 11 | #import "base/ios/block_types.h"
|
|
56 | 57 | #error "This file requires ARC support."
|
57 | 58 | #endif
|
58 | 59 |
|
| 60 | +class ScrollingTimeLogger { |
| 61 | + public: |
| 62 | + ScrollingTimeLogger() : start_(base::TimeTicks::Now()) {} |
| 63 | + ~ScrollingTimeLogger() { |
| 64 | + base::TimeDelta duration = base::TimeTicks::Now() - start_; |
| 65 | + base::UmaHistogramTimes("IOS.TabSwitcher.TimeSpentScrolling", duration); |
| 66 | + } |
| 67 | + |
| 68 | + private: |
| 69 | + base::TimeTicks start_; |
| 70 | +}; |
| 71 | + |
59 | 72 | namespace {
|
60 | 73 |
|
61 | 74 | // Constants used in the spring animation when inserting items in the thumb
|
@@ -171,10 +184,13 @@ @interface GridViewController () <GridCellDelegate,
|
171 | 184 | @property(nonatomic, assign) NSInteger inactiveTabsDaysThreshold;
|
172 | 185 | // Tracks if a drop action initiated in this grid is in progress.
|
173 | 186 | @property(nonatomic) BOOL localDragActionInProgress;
|
174 |
| - |
175 | 187 | @end
|
176 | 188 |
|
177 |
| -@implementation GridViewController |
| 189 | +@implementation GridViewController { |
| 190 | + // Tracks when the grid view is scrolling. Create a new instance to start |
| 191 | + // timing and reset to stop and log the associated time histogram. |
| 192 | + std::unique_ptr<ScrollingTimeLogger> _scrollingTimeLogger; |
| 193 | +} |
178 | 194 |
|
179 | 195 | @synthesize thumbStripEnabled = _thumbStripEnabled;
|
180 | 196 |
|
@@ -1099,6 +1115,23 @@ - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
|
1099 | 1115 |
|
1100 | 1116 | - (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
|
1101 | 1117 | [self.delegate gridViewControllerWillBeginDragging:self];
|
| 1118 | + base::RecordAction(base::UserMetricsAction("MobileTabGridUserScrolled")); |
| 1119 | + _scrollingTimeLogger = std::make_unique<ScrollingTimeLogger>(); |
| 1120 | +} |
| 1121 | + |
| 1122 | +- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView |
| 1123 | + willDecelerate:(BOOL)decelerate { |
| 1124 | + if (!decelerate) { |
| 1125 | + _scrollingTimeLogger = nullptr; |
| 1126 | + } |
| 1127 | +} |
| 1128 | + |
| 1129 | +- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView { |
| 1130 | + _scrollingTimeLogger = nullptr; |
| 1131 | +} |
| 1132 | + |
| 1133 | +- (void)scrollViewDidScrollToTop:(UIScrollView*)scrollView { |
| 1134 | + base::RecordAction(base::UserMetricsAction("MobileTabGridUserScrolledToTop")); |
1102 | 1135 | }
|
1103 | 1136 |
|
1104 | 1137 | - (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView*)scrollView {
|
|
0 commit comments