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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/TapDurationSuppression.java

Issue 2932623002: [TTS] Add onTouchDown to GestureStateListener. (Closed)
Patch Set: Adjusted the custom histograms to write all values and use a max of 1000 with 100 buckets. Created 3 years, 5 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/android/java/src/org/chromium/chrome/browser/contextualsearch/TapDurationSuppression.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/TapDurationSuppression.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/TapDurationSuppression.java
new file mode 100644
index 0000000000000000000000000000000000000000..3d7115362f767d71bf4867250d88c5792482e91c
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/TapDurationSuppression.java
@@ -0,0 +1,58 @@
+// Copyright 2017 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.
+
+package org.chromium.chrome.browser.contextualsearch;
+
+/**
+ * Provides a signal for the duration of a Tap being either brief or lengthy.
+ * This signal could be used for suppression of taps below some threshold, so we aggregate-log too.
+ * We log CTR to UMA for Taps shorter and longer than the threshold.
+ */
+class TapDurationSuppression extends ContextualSearchHeuristic {
+ private static final int DEFAULT_TAP_DURATION_THRESHOLD_MS = 70;
+
+ private final int mTapDurationMs;
+ private final int mTapDurationThresholdMs;
+ private final boolean mIsTapDurationConditionSatisfied;
+
+ /**
+ * Constructs a heuristic to categorize the Tap based on duration as either short or long.
+ * @param tapDurationMs The duration of the tap in milliseconds.
+ */
+ TapDurationSuppression(int tapDurationMs) {
+ mTapDurationMs = tapDurationMs;
+ mTapDurationThresholdMs = ContextualSearchFieldTrial.getTapDurationThresholdMs();
+ int tapDurationThreshold = mTapDurationThresholdMs != 0 ? mTapDurationThresholdMs
+ : DEFAULT_TAP_DURATION_THRESHOLD_MS;
+ mIsTapDurationConditionSatisfied = tapDurationMs < tapDurationThreshold;
+ }
+
+ @Override
+ protected boolean isConditionSatisfiedAndEnabled() {
+ return mIsTapDurationConditionSatisfied && mTapDurationThresholdMs != 0;
+ }
+
+ @Override
+ protected void logResultsSeen(boolean wasSearchContentViewSeen, boolean wasActivatedByTap) {
+ if (wasActivatedByTap) {
+ ContextualSearchUma.logTapDurationSeen(
+ wasSearchContentViewSeen, mIsTapDurationConditionSatisfied);
+
+ // TODO(donnd): remove when logging to Ranker is done!
+ ContextualSearchUma.logTapDuration(wasSearchContentViewSeen, mTapDurationMs);
+ }
+ }
+
+ // TODO(donnd): Log the actual tap duration to Ranker once we have privacy-approval!
+
+ @Override
+ protected boolean shouldAggregateLogForTapSuppression() {
+ return true;
+ }
+
+ @Override
+ protected boolean isConditionSatisfiedForAggregateLogging() {
+ return mIsTapDurationConditionSatisfied;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698