Skip to content

Commit efe2a7a

Browse files
ArcankChromium LUCI CQ
authored and
Chromium LUCI CQ
committed
[5735] Add scrolling metrics in grid views
This CL adds metrics to track scrolling actions in grid views: - events when the user scrolls; - cumulative time spent scrolling. (cherry picked from commit 63e25d1) Fixed: 1439234 Change-Id: Id5e5c3bb0739359ddd6670f4de10789c3c25ca35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4466313 Auto-Submit: Louis Romero <lpromero@google.com> Reviewed-by: Aliona Dangla <alionadangla@chromium.org> Reviewed-by: Gauthier Ambard <gambard@chromium.org> Commit-Queue: Louis Romero <lpromero@google.com> Reviewed-by: Olivier Robin <olivierrobin@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1136168} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4484223 Commit-Queue: Gauthier Ambard <gambard@chromium.org> Cr-Commit-Position: refs/branch-heads/5735@{#44} Cr-Branched-From: 2f562e4-refs/heads/main@{#1135570}
1 parent df3138f commit efe2a7a

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.mm

+35-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.h"
66

77
#import <algorithm>
8+
#import <memory>
89

910
#import "base/check_op.h"
1011
#import "base/ios/block_types.h"
@@ -56,6 +57,18 @@
5657
#error "This file requires ARC support."
5758
#endif
5859

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+
5972
namespace {
6073

6174
// Constants used in the spring animation when inserting items in the thumb
@@ -171,10 +184,13 @@ @interface GridViewController () <GridCellDelegate,
171184
@property(nonatomic, assign) NSInteger inactiveTabsDaysThreshold;
172185
// Tracks if a drop action initiated in this grid is in progress.
173186
@property(nonatomic) BOOL localDragActionInProgress;
174-
175187
@end
176188

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+
}
178194

179195
@synthesize thumbStripEnabled = _thumbStripEnabled;
180196

@@ -1099,6 +1115,23 @@ - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
10991115

11001116
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
11011117
[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"));
11021135
}
11031136

11041137
- (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView*)scrollView {

tools/metrics/actions/actions.xml

+17
Original file line numberDiff line numberDiff line change
@@ -21817,6 +21817,23 @@ should be able to be added at any place in this file.
2181721817
</description>
2181821818
</action>
2181921819

21820+
<action name="MobileTabGridUserScrolled">
21821+
<owner>lpromero@chromium.org</owner>
21822+
<owner>alionadangla@chromium.org</owner>
21823+
<owner>chromeleon@google.com</owner>
21824+
<description>User in the iOS tab grid scrolled the grid of tabs.</description>
21825+
</action>
21826+
21827+
<action name="MobileTabGridUserScrolledToTop">
21828+
<owner>lpromero@chromium.org</owner>
21829+
<owner>alionadangla@chromium.org</owner>
21830+
<owner>chromeleon@google.com</owner>
21831+
<description>
21832+
User in the iOS tab grid tapped the status bar to scroll to the top of the
21833+
grid of tabs.
21834+
</description>
21835+
</action>
21836+
2182021837
<action name="MobileTabNewTab">
2182121838
<owner>ewannpv@chromium.org</owner>
2182221839
<owner>gambard@chromium.org</owner>

tools/metrics/histograms/metadata/ios/histograms.xml

+11
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,17 @@ chromium-metrics-reviews@google.com.
23472347
</summary>
23482348
</histogram>
23492349

2350+
<histogram name="IOS.TabSwitcher.TimeSpentScrolling" units="ms"
2351+
expires_after="2024-05-14">
2352+
<owner>lpromero@chromium.org</owner>
2353+
<owner>alionadangla@chromium.org</owner>
2354+
<owner>chromeleon@google.com</owner>
2355+
<summary>
2356+
The time spent while the tab grid is scrolled by the user. This includes the
2357+
deceleration time.
2358+
</summary>
2359+
</histogram>
2360+
23502361
<histogram name="IOS.TextSelection.EntityDetection.DetectedEntityType"
23512362
enum="TextSelectionDetectedEntityType" expires_after="2023-10-08">
23522363
<owner>rajendrant@chromium.org</owner>

0 commit comments

Comments
 (0)