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

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

Issue 2828793002: Refactoring ChildProcessConnection. (Closed)
Patch Set: More test fixing. Created 3 years, 8 months 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
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;

Powered by Google App Engine
This is Rietveld 408576698