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

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

Issue 2544753002: Reuse InputConnectionHandlerThread (Closed)
Patch Set: Created 4 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5953108d0dcbb022823abe77e1da4c194c84ab5f..5a3f094ab799b7159dff7fce82fd2b0ec3d7463c 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
+ // 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")
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());
}
@VisibleForTesting
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698