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 4173d40abc8b8faf26a6a4d42018b340070db816..c3ea38dcd4f2351ab9d9f946728f8db1afeea93a 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 |
@@ -30,6 +31,10 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti |
// UI message loop until View#hasWindowFocus() is aligned with what IMMS sees. |
private static final int CHECK_REGISTER_RETRY = 1; |
+ // Reused for multiple WebView instances. TODO(changwan): check if we need to quit the loop |
Torne
2016/12/01 11:01:59
No, you don't; none of our other global threads ex
Changwan Ryu
2016/12/02 09:06:49
Thanks for the explanation. Comment is removed.
|
+ // for the last webview instance. |
+ private static HandlerThread sHandlerThread; |
+ |
private final Handler mHandler; |
private final InputMethodManagerWrapper mInputMethodManagerWrapper; |
private final InputMethodUma mInputMethodUma; |
@@ -61,11 +66,14 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti |
} |
@VisibleForTesting |
+ @SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") |
Torne
2016/12/01 11:01:58
If you suppress a thread safety warning you should
Changwan Ryu
2016/12/02 09:06:49
I'll go ahead with option 2). I didn't realize tha
|
protected Handler createHandler() { |
- HandlerThread thread = |
- new HandlerThread("InputConnectionHandlerThread", HandlerThread.NORM_PRIORITY); |
- thread.start(); |
- return new Handler(thread.getLooper()); |
+ if (sHandlerThread == null) { |
+ sHandlerThread = |
+ new HandlerThread("InputConnectionHandlerThread", HandlerThread.NORM_PRIORITY); |
+ sHandlerThread.start(); |
+ } |
+ return new Handler(sHandlerThread.getLooper()); |
Torne
2016/12/01 11:01:59
Is it actually necessary to make a new handler eve
Changwan Ryu
2016/12/02 09:06:49
Not at all. I just tried very hard to minimize the
|
} |
@VisibleForTesting |