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

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

Issue 2543893002: Reuse InputConnectionHandlerThread (Closed)
Patch Set: fixed findit failure 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 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
« 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