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

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

Issue 2826803002: Add UMA for CopylessPaste cache (Closed)
Patch Set: fix junit tests Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/AppIndexingUtilTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java
index f0398fc37324fec487b7c25f2113939fbe54ab3f..2f9fbc51b1d18da6280bce65f2e1af12a3e5e65b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java
@@ -11,6 +11,7 @@ import android.webkit.URLUtil;
import org.chromium.base.Callback;
import org.chromium.base.SysUtils;
import org.chromium.base.VisibleForTesting;
+import org.chromium.base.metrics.RecordHistogram;
import org.chromium.blink.mojom.document_metadata.CopylessPaste;
import org.chromium.blink.mojom.document_metadata.WebPage;
import org.chromium.chrome.browser.historyreport.AppIndexingReporter;
@@ -32,6 +33,13 @@ public class AppIndexingUtil {
private static Callback<WebPage> sCallbackForTesting;
+ // Constants used to log UMA "enum" histograms about the cache state.
+ // The values should not be changed or reused, and CACHE_HISTOGRAM_BOUNDARY should be the last.
+ private static final int CACHE_HIT_WITH_ENTITY = 0;
+ private static final int CACHE_HIT_WITHOUT_ENTITY = 1;
+ private static final int CACHE_MISS = 2;
+ private static final int CACHE_HISTOGRAM_BOUNDARY = 3;
+
/**
* Extracts entities from document metadata and reports it to on-device App Indexing.
* This call can cache entities from recently parsed webpages, in which case, only the url and
@@ -52,11 +60,18 @@ public class AppIndexingUtil {
if (wasPageVisitedRecently(url)) {
if (lastPageVisitContainedEntity(url)) {
// Condition 1
+ RecordHistogram.recordEnumeratedHistogram(
+ "CopylessPaste.CacheHit", CACHE_HIT_WITH_ENTITY, CACHE_HISTOGRAM_BOUNDARY);
getAppIndexingReporter().reportWebPageView(url, tab.getTitle());
+ return;
}
// Condition 2
+ RecordHistogram.recordEnumeratedHistogram(
+ "CopylessPaste.CacheHit", CACHE_HIT_WITHOUT_ENTITY, CACHE_HISTOGRAM_BOUNDARY);
} else {
// Condition 3
+ RecordHistogram.recordEnumeratedHistogram(
+ "CopylessPaste.CacheHit", CACHE_MISS, CACHE_HISTOGRAM_BOUNDARY);
CopylessPaste copylessPaste = getCopylessPasteInterface(tab);
if (copylessPaste == null) {
return;
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/AppIndexingUtilTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698