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

Unified Diff: content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java

Issue 2861673009: android: Remove ChildProcessServiceImpl.sContext (Closed)
Patch Set: Created 3 years, 7 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
« 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/app/ChildProcessServiceImpl.java
diff --git a/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java b/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java
index 7a8f92c04e3c28a529dd049f4bfbeb67e420d1a3..90be9faa7c2b638b5b8d37382981a79791122d3f 100644
--- a/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java
+++ b/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java
@@ -40,7 +40,6 @@ import org.chromium.content.common.IGpuProcessCallback;
import org.chromium.content.common.SurfaceWrapper;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.atomic.AtomicReference;
/**
* This class implements all of the functionality for {@link ChildProcessService} which owns an
@@ -57,6 +56,9 @@ public class ChildProcessServiceImpl {
private static final String MAIN_THREAD_NAME = "ChildProcessMain";
private static final String TAG = "ChildProcessService";
+ // Only for a check that create is only called once.
+ private static boolean sCreateCalled;
+
// Lock that protects the following members.
private final Object mBinderLock = new Object();
private IGpuProcessCallback mGpuCallback;
@@ -77,7 +79,6 @@ public class ChildProcessServiceImpl {
// Child library process type.
private int mLibraryProcessType;
- private static AtomicReference<Context> sContext = new AtomicReference<>(null);
private boolean mLibraryInitialized;
/**
@@ -165,23 +166,20 @@ public class ChildProcessServiceImpl {
// The ClassLoader for the host context.
private ClassLoader mHostClassLoader;
- /* package */ static Context getContext() {
- return sContext.get();
- }
-
/**
* Loads Chrome's native libraries and initializes a ChildProcessServiceImpl.
* @param context The application context.
* @param hostContext The host context the library should be loaded with (i.e. Chrome).
*/
+ @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") // For sCreateCalled check.
@UsedByReflection("WebApkSandboxedProcessService")
public void create(final Context context, final Context hostContext) {
mHostClassLoader = hostContext.getClassLoader();
Log.i(TAG, "Creating new ChildProcessService pid=%d", Process.myPid());
- if (sContext.get() != null) {
+ if (sCreateCalled) {
throw new RuntimeException("Illegal child process reuse.");
}
- sContext.set(context);
+ sCreateCalled = true;
// Initialize the context for the application that owns this ChildProcessServiceImpl object.
ContextUtils.initApplicationContext(context);
« 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