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

Unified Diff: base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java

Issue 2735113003: Changing SpawnChild to return a struct.
Patch Set: Created 3 years, 9 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: base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java
diff --git a/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java b/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java
index 6c1f3981f9afdc0586d5067047cce5374bef9410..569c739dec1733d6f4156161d0428e27520bd83b 100644
--- a/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java
+++ b/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java
@@ -30,7 +30,7 @@ import javax.annotation.concurrent.GuardedBy;
public final class MultiprocessTestClientLauncher {
private static final String TAG = "cr_MProcTCLauncher";
- private static ConnectionAllocator sConnectionAllocator = new ConnectionAllocator();
+ private static final ConnectionAllocator sConnectionAllocator = new ConnectionAllocator();
// Not supposed to be instantiated.
private MultiprocessTestClientLauncher() {}
@@ -106,6 +106,9 @@ public final class MultiprocessTestClientLauncher {
@GuardedBy("mConnectedLock")
private boolean mConnected;
private int mPid;
+ private ParcelableChannelClient mParcelableChannelClient;
+ private final ParcelableChannelServer mParcelableChannelServer =
+ new ParcelableChannelServer("PARENT PROCESS");
ClientServiceConnection(int slot, String[] commandLine, FileDescriptorInfo[] filesToMap) {
mSlot = slot;
@@ -129,7 +132,13 @@ public final class MultiprocessTestClientLauncher {
public void onServiceConnected(ComponentName className, IBinder service) {
try {
mService = ITestClient.Stub.asInterface(service);
- mPid = mService.launch(mCommandLine, mFilesToMap);
+ int[] pid = {-1};
+ mParcelableChannelServer.clearReceivedParcelables();
+ IParcelableChannel iParcelableChannel =
+ mService.launch(mCommandLine, mFilesToMap, mParcelableChannelServer, pid);
+ mParcelableChannelClient = new ParcelableChannelClient(iParcelableChannel);
+ mPid = pid[0];
+
synchronized (mConnectedLock) {
mConnected = true;
mConnectedLock.notifyAll();
@@ -145,6 +154,10 @@ public final class MultiprocessTestClientLauncher {
Log.e(TAG, "Early ClientServiceConnection disconnection.");
return;
}
+ synchronized (mConnectedLock) {
+ mConnected = false;
+ }
+ mParcelableChannelClient = null;
sConnectionAllocator.freeConnection(this);
}
@@ -152,6 +165,14 @@ public final class MultiprocessTestClientLauncher {
return mService;
}
+ public ParcelableChannelClient getParcelableChannelClient() {
+ return mParcelableChannelClient;
+ }
+
+ public ParcelableChannelServer getParcelableChannelServer() {
+ return mParcelableChannelServer;
+ }
+
public String getServiceClassName() {
// In order to use different processes, we have to declare multiple services in the
// AndroidManifest.xml file, each service associated with its own process. The various
@@ -184,8 +205,8 @@ public final class MultiprocessTestClientLauncher {
* @return the PID of the started process or 0 if the process could not be started.
*/
@CalledByNative
- private static int launchClient(final Context context, final String[] commandLine,
- final FileDescriptorInfo[] filesToMap) {
+ private static LaunchClientResult launchClient(final Context context,
+ final String[] commandLine, final FileDescriptorInfo[] filesToMap) {
if (ThreadUtils.runningOnUiThread()) {
// This can't be called on the main thread as the native side will block until
// onServiceConnected above is called, which cannot happen if the main thread is
@@ -202,12 +223,13 @@ public final class MultiprocessTestClientLauncher {
intent, connection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT)) {
Log.e(TAG, "Failed to bind service: " + context.getPackageName() + "." + className);
sConnectionAllocator.freeConnection(connection);
- return 0;
+ return new LaunchClientResult(0, null, null);
}
connection.waitForConnection();
- return connection.getPid();
+ return new LaunchClientResult(connection.getPid(), connection.getParcelableChannelClient(),
+ connection.getParcelableChannelServer());
}
/**

Powered by Google App Engine
This is Rietveld 408576698