Index: content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java b/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
index 622b92bf67b700ce02f5da03ea6304516cf72ab0..f9732a60cdf3f2313b900b3c943a0ffb594c54da 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
@@ -8,6 +8,7 @@ import android.os.Handler; |
import android.os.Looper; |
import org.chromium.base.JavaHandlerThread; |
+import org.chromium.base.VisibleForTesting; |
import org.chromium.base.annotations.CalledByNative; |
import org.chromium.base.annotations.JNINamespace; |
@@ -16,10 +17,13 @@ import org.chromium.base.annotations.JNINamespace; |
public final class LauncherThread { |
private static final JavaHandlerThread sThread = |
new JavaHandlerThread("Chrome_ProcessLauncherThread"); |
- private static final Handler sHandler; |
+ private static final Handler sThreadHandler; |
+ // Can be overritten in tests. |
+ private static Handler sHandler; |
static { |
sThread.maybeStart(); |
- sHandler = new Handler(sThread.getLooper()); |
+ sThreadHandler = new Handler(sThread.getLooper()); |
+ sHandler = sThreadHandler; |
} |
public static void post(Runnable r) { |
@@ -34,6 +38,16 @@ public final class LauncherThread { |
return sHandler.getLooper() == Looper.myLooper(); |
} |
+ @VisibleForTesting |
+ public static void setCurrentThreadAsLauncherThread() { |
+ sHandler = new Handler(); |
+ } |
+ |
+ @VisibleForTesting |
+ public static void setLauncherThreadAsLauncherThread() { |
+ sHandler = sThreadHandler; |
+ } |
+ |
@CalledByNative |
private static JavaHandlerThread getHandlerThread() { |
return sThread; |