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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java

Issue 2613863006: Add a ThreadLocal flag to replace the reflection in shouldTriggerDelayedOnCreateInputConnection() (Closed)
Patch Set: fix cast error Created 3 years, 11 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: content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java b/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
index d3ed0fc2fc21afff95b6654cc804cb731e4b9ed6..5dec39a36ebfe8f7d93cdb8b33d39dd4ce743722 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
@@ -11,6 +11,7 @@ import android.view.inputmethod.EditorInfo;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
+import org.chromium.base.annotations.SuppressFBWarnings;
/**
* A factory class for {@link ThreadedInputConnection}. The class also includes triggering
@@ -37,6 +38,15 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
private CheckInvalidator mCheckInvalidator;
private boolean mReentrantTriggering;
+ private static ThreadLocal<Boolean> sTriggerDelayedOnCreateInputConnection =
+ new ThreadLocal<Boolean>() {
+ @SuppressFBWarnings("CHROMIUM_SYNCHRONIZED_METHOD")
+ @Override
+ protected synchronized Boolean initialValue() {
+ return true;
+ }
+ };
+
// Initialization-on-demand holder for Handler.
private static class LazyHandlerHolder {
// Note that we never exit this thread to avoid lifetime or thread-safety issues.
@@ -71,6 +81,11 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
}
@Override
+ public void setTriggerDelayedOnCreateInputConnection(final boolean trigger) {
+ sTriggerDelayedOnCreateInputConnection.set(trigger);
+ }
+
+ @Override
public Handler getHandler() {
return LazyHandlerHolder.sHandler;
}
@@ -106,6 +121,10 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
return true;
}
+ private boolean shouldTriggerDelayedOnCreateInputConnection2() {
+ return sTriggerDelayedOnCreateInputConnection.get();
+ }
+
@Override
public ThreadedInputConnection initializeAndGet(View view, ImeAdapter imeAdapter, int inputType,
int inputFlags, int inputMode, int selectionStart, int selectionEnd,
@@ -124,6 +143,9 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
// mServedConnecting.
if (mCheckInvalidator != null) mCheckInvalidator.invalidate();
yabinh 2017/01/09 07:33:11 Keep the old method for debugging.
+ assert shouldTriggerDelayedOnCreateInputConnection()
+ == shouldTriggerDelayedOnCreateInputConnection2();
+
if (shouldTriggerDelayedOnCreateInputConnection()) {
triggerDelayedOnCreateInputConnection(view);
return null;

Powered by Google App Engine
This is Rietveld 408576698