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

Unified Diff: components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java

Issue 2457873002: [Android] spellcheck: add latency UMA. (Closed)
Patch Set: address comments, use java UMA api Created 4 years, 1 month 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 | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
diff --git a/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java b/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
index 0804e1469b36a538356a0e28d92d93875eddc61e..bcedb75bc3074c77a8b088216014863df548aea7 100644
--- a/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
+++ b/components/spellcheck/browser/android/java/src/org/chromium/components/spellcheck/SpellCheckerSessionBridge.java
@@ -5,6 +5,7 @@
package org.chromium.components.spellcheck;
import android.content.Context;
+import android.os.SystemClock;
import android.view.textservice.SentenceSuggestionsInfo;
import android.view.textservice.SpellCheckerSession;
import android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener;
@@ -14,8 +15,10 @@ import android.view.textservice.TextServicesManager;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.metrics.RecordHistogram;
import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
/**
* JNI interface for native SpellCheckerSessionBridge to use Android's spellchecker.
@@ -23,6 +26,8 @@ import java.util.ArrayList;
public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
private long mNativeSpellCheckerSessionBridge;
private final SpellCheckerSession mSpellCheckerSession;
+ private long mStartMs;
+ private long mStopMs;
/**
* Constructs a SpellCheckerSessionBridge object as well as its SpellCheckerSession object.
@@ -83,6 +88,7 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
if (text.endsWith(".")) {
text = text.substring(0, text.length() - 1);
}
+ mStartMs = SystemClock.elapsedRealtime();
mSpellCheckerSession.getSentenceSuggestions(new TextInfo[] {new TextInfo(text)}, 0);
}
@@ -92,6 +98,8 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
*/
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
+ mStopMs = SystemClock.elapsedRealtime();
+
if (mNativeSpellCheckerSessionBridge == 0) {
return;
}
@@ -118,6 +126,9 @@ public class SpellCheckerSessionBridge implements SpellCheckerSessionListener {
}
nativeProcessSpellCheckResults(mNativeSpellCheckerSessionBridge,
convertListToArray(offsets), convertListToArray(lengths));
+
+ RecordHistogram.recordTimesHistogram("SpellCheck.Android.Latency",
+ mStopMs - mStartMs, TimeUnit.MILLISECONDS);
}
/**
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698