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 03c1fe5f207b9a3dc09d62ee44738850e788101f..4173d40abc8b8faf26a6a4d42018b340070db816 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 |
@@ -10,7 +10,6 @@ |
import android.view.inputmethod.EditorInfo; |
import org.chromium.base.Log; |
-import org.chromium.base.ThreadUtils; |
import org.chromium.base.VisibleForTesting; |
/** |
@@ -31,7 +30,7 @@ |
// UI message loop until View#hasWindowFocus() is aligned with what IMMS sees. |
private static final int CHECK_REGISTER_RETRY = 1; |
- private Handler mHandler; |
+ private final Handler mHandler; |
private final InputMethodManagerWrapper mInputMethodManagerWrapper; |
private final InputMethodUma mInputMethodUma; |
private ThreadedInputConnectionProxyView mProxyView; |
@@ -57,6 +56,7 @@ |
ThreadedInputConnectionFactory(InputMethodManagerWrapper inputMethodManagerWrapper) { |
mInputMethodManagerWrapper = inputMethodManagerWrapper; |
+ mHandler = createHandler(); |
mInputMethodUma = createInputMethodUma(); |
} |
@@ -66,25 +66,6 @@ |
new HandlerThread("InputConnectionHandlerThread", HandlerThread.NORM_PRIORITY); |
thread.start(); |
return new Handler(thread.getLooper()); |
- } |
- |
- private void destroyHandler() { |
- if (mHandler == null) return; |
- final Handler handler = mHandler; |
- handler.post(new Runnable() { |
- @Override |
- public void run() { |
- ThreadUtils.postOnUiThread(new Runnable() { |
- @Override |
- public void run() { |
- if (handler != null) { |
- handler.getLooper().quit(); |
- } |
- } |
- }); |
- } |
- }); |
- mHandler = null; |
} |
@VisibleForTesting |
@@ -136,8 +117,6 @@ |
// mServedConnecting. |
if (mCheckInvalidator != null) mCheckInvalidator.invalidate(); |
- if (mHandler == null) mHandler = createHandler(); |
- |
if (shouldTriggerDelayedOnCreateInputConnection()) { |
triggerDelayedOnCreateInputConnection(view); |
return null; |
@@ -166,7 +145,6 @@ |
if (!view.hasWindowFocus()) mCheckInvalidator.invalidate(); |
- if (mHandler == null) return; |
// We cannot reuse the existing proxy view, if any, due to crbug.com/664402. |
mProxyView = createProxyView(mHandler, view); |
@@ -195,7 +173,6 @@ |
// Step 3: Check that the above hack worked. |
// Do not check until activation finishes inside InputMethodManager (on IME thread). |
- if (mHandler == null) return; |
mHandler.post(new Runnable() { |
@Override |
public void run() { |
@@ -274,7 +251,6 @@ |
public void onViewAttachedToWindow() { |
if (DEBUG_LOGS) Log.d(TAG, "onViewAttachedToWindow"); |
if (mProxyView != null) mProxyView.onOriginalViewAttachedToWindow(); |
- if (mHandler == null) mHandler = createHandler(); |
} |
@Override |
@@ -282,12 +258,5 @@ |
if (DEBUG_LOGS) Log.d(TAG, "onViewDetachedFromWindow"); |
if (mCheckInvalidator != null) mCheckInvalidator.invalidate(); |
if (mProxyView != null) mProxyView.onOriginalViewDetachedFromWindow(); |
- destroyHandler(); |
- } |
- |
- @Override |
- public void destroy() { |
- if (mCheckInvalidator != null) mCheckInvalidator.invalidate(); |
- destroyHandler(); |
} |
} |