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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java

Issue 2894913003: [TTS] Move Ranker logging to inference time. (Closed)
Patch Set: Fix some asserts and minor cleanup. Created 3 years, 7 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.chrome.browser.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 8
9 import org.chromium.base.VisibleForTesting; 9 import org.chromium.base.VisibleForTesting;
10 import org.chromium.chrome.browser.ChromeActivity; 10 import org.chromium.chrome.browser.ChromeActivity;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 mLastTapState = null; 344 mLastTapState = null;
345 mHandler.handleInvalidTap(); 345 mHandler.handleInvalidTap();
346 } 346 }
347 } 347 }
348 348
349 /** 349 /**
350 * Handles Tap suppression by making a callback to either the handler's #han dleSuppressedTap() 350 * Handles Tap suppression by making a callback to either the handler's #han dleSuppressedTap()
351 * or #handleNonSuppressedTap() after a possible delay. 351 * or #handleNonSuppressedTap() after a possible delay.
352 * This should be called when the context is fully built (by gathering surro unding text 352 * This should be called when the context is fully built (by gathering surro unding text
353 * if needed, etc) but before showing any UX. 353 * if needed, etc) but before showing any UX.
354 * @param rankerLogger The {@link ContextualSearchRankerLogger} currently be ing used to measure
355 * or suppress the UI by Ranker.
354 */ 356 */
355 void handleShouldSuppressTap() { 357 void handleShouldSuppressTap(ContextualSearchRankerLogger rankerLogger) {
356 int x = (int) mX; 358 int x = (int) mX;
357 int y = (int) mY; 359 int y = (int) mY;
358 360
359 // TODO(donnd): add a policy method to get adjusted tap count. 361 // TODO(donnd): add a policy method to get adjusted tap count.
360 ChromePreferenceManager prefs = ChromePreferenceManager.getInstance(); 362 ChromePreferenceManager prefs = ChromePreferenceManager.getInstance();
361 int adjustedTapsSinceOpen = prefs.getContextualSearchTapCount() 363 int adjustedTapsSinceOpen = prefs.getContextualSearchTapCount()
362 - prefs.getContextualSearchTapQuickAnswerCount(); 364 - prefs.getContextualSearchTapQuickAnswerCount();
363 TapSuppressionHeuristics tapHeuristics = 365 TapSuppressionHeuristics tapHeuristics =
364 new TapSuppressionHeuristics(this, mLastTapState, x, y, adjusted TapsSinceOpen); 366 new TapSuppressionHeuristics(this, mLastTapState, x, y, adjusted TapsSinceOpen);
365 // TODO(donnd): Move to be called when the panel closes to work with sta tes that change. 367 // TODO(donnd): Move to be called when the panel closes to work with sta tes that change.
366 tapHeuristics.logConditionState(); 368 tapHeuristics.logConditionState();
Theresa 2017/05/30 20:25:25 nit: add a blank line after this line and before t
Donn Denman 2017/05/30 23:13:25 Done.
369 tapHeuristics.logRankerTapSuppression(rankerLogger);
367 // Tell the manager what it needs in order to log metrics on whether the tap would have 370 // Tell the manager what it needs in order to log metrics on whether the tap would have
368 // been suppressed if each of the heuristics were satisfied. 371 // been suppressed if each of the heuristics were satisfied.
369 mHandler.handleMetricsForWouldSuppressTap(tapHeuristics); 372 mHandler.handleMetricsForWouldSuppressTap(tapHeuristics);
370 373
371 boolean shouldSuppressTap = tapHeuristics.shouldSuppressTap(); 374 boolean shouldSuppressTapBasedOnHeuristics = tapHeuristics.shouldSuppres sTap();
372 if (mTapTimeNanoseconds != 0) { 375 if (mTapTimeNanoseconds != 0) {
373 // Remember the tap state for subsequent tap evaluation. 376 // Remember the tap state for subsequent tap evaluation.
374 mLastTapState = 377 mLastTapState = new ContextualSearchTapState(
375 new ContextualSearchTapState(x, y, mTapTimeNanoseconds, shou ldSuppressTap); 378 x, y, mTapTimeNanoseconds, shouldSuppressTapBasedOnHeuristic s);
376 } else { 379 } else {
377 mLastTapState = null; 380 mLastTapState = null;
378 } 381 }
379 382
380 if (shouldSuppressTap) { 383 boolean shouldSuppressTapBasedOnRanker = rankerLogger.inferUiSuppression ();
384 if (shouldSuppressTapBasedOnHeuristics || shouldSuppressTapBasedOnRanker ) {
381 mHandler.handleSuppressedTap(); 385 mHandler.handleSuppressedTap();
382 } else { 386 } else {
383 mHandler.handleNonSuppressedTap(); 387 mHandler.handleNonSuppressedTap(mTapTimeNanoseconds);
384 } 388 }
385 } 389 }
386 390
387 /** 391 /**
388 * Gets the base page ContentViewCore. 392 * Gets the base page ContentViewCore.
389 * Deprecated, use getBaseWebContents instead. 393 * Deprecated, use getBaseWebContents instead.
390 * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab. 394 * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab.
391 */ 395 */
392 @Deprecated 396 @Deprecated
393 ContentViewCore getBaseContentView() { 397 ContentViewCore getBaseContentView() {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher. 556 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher.
553 while (matcher.find()) { 557 while (matcher.find()) {
554 if (startOffset >= matcher.start() && endOffset <= matcher.end()) { 558 if (startOffset >= matcher.start() && endOffset <= matcher.end()) {
555 return true; 559 return true;
556 } 560 }
557 } 561 }
558 562
559 return false; 563 return false;
560 } 564 }
561 } 565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698