Commit 74a2272c authored by boliu's avatar boliu Committed by Commit bot

android: Remove command line args from intent bundle

The intent can be saved by android and re-used for launching a child
service in edge cases. However the command line arguments are different
for each launch of the child process. The command line args are already
passed through an additional bundle through the aidl interface. So just
fallback to the aidl bundle and remove command line args from the intent
bundle.

Note this may and probably does decrease parallelism in child service
start up, thus causing a perf regression.

BUG=664341

Review-Url: https://codereview.chromium.org/2560403002
Cr-Commit-Position: refs/heads/master@{#437929}
parent 7b7e0956
......@@ -6,7 +6,6 @@ package org.chromium.content.app;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import org.chromium.base.annotations.JNINamespace;
......@@ -48,20 +47,4 @@ public class ChildProcessService extends Service {
stopSelf();
return mChildProcessServiceImpl.bind(intent, -1);
}
/**
* Helper method to initialize the params from intent.
* @param intent Intent to launch the service.
*/
protected void initializeParams(Intent intent) {
mChildProcessServiceImpl.initializeParams(intent);
}
/**
* Helper method to get the information about the service from a given bundle.
* @param bundle Bundle that contains the information to start the service.
*/
protected void getServiceInfo(Bundle bundle) {
mChildProcessServiceImpl.getServiceInfo(bundle);
}
}
......@@ -70,8 +70,6 @@ public class ChildProcessServiceImpl {
private static AtomicReference<Context> sContext = new AtomicReference<>(null);
private boolean mLibraryInitialized = false;
// Becomes true once the service is bound. Access must synchronize around mMainThread.
private boolean mIsBound = false;
/**
* If >= 0 enables "validation of caller of {@link mBinder}'s methods". A RemoteException
......@@ -164,11 +162,7 @@ public class ChildProcessServiceImpl {
Linker linker = null;
boolean requestedSharedRelro = false;
if (Linker.isUsed()) {
synchronized (mMainThread) {
while (!mIsBound) {
mMainThread.wait();
}
}
assert mLinkerParams != null;
linker = getLinker();
if (mLinkerParams.mWaitForSharedRelro) {
requestedSharedRelro = true;
......@@ -282,28 +276,24 @@ public class ChildProcessServiceImpl {
return mBinder;
}
void initializeParams(Intent intent) {
private void initializeParams(Intent intent) {
synchronized (mMainThread) {
mCommandLineParams =
intent.getStringArrayExtra(ChildProcessConstants.EXTRA_COMMAND_LINE);
// mLinkerParams is never used if Linker.isUsed() returns false.
// See onCreate().
mLinkerParams = new ChromiumLinkerParams(intent);
mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent);
mIsBound = true;
mMainThread.notifyAll();
}
}
void getServiceInfo(Bundle bundle) {
private void getServiceInfo(Bundle bundle) {
// Required to unparcel FileDescriptorInfo.
bundle.setClassLoader(mHostClassLoader);
synchronized (mMainThread) {
// Allow the command line to be set via bind() intent or setupConnection, but
// the FD can only be transferred here.
if (mCommandLineParams == null) {
mCommandLineParams =
bundle.getStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE);
mMainThread.notifyAll();
}
// We must have received the command line by now
assert mCommandLineParams != null;
......
......@@ -130,9 +130,9 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
try {
TraceEvent.begin("ChildProcessConnectionImpl.ChildServiceConnection.bind");
final Intent intent = createServiceBindIntent();
if (commandLine != null) {
intent.putExtra(ChildProcessConstants.EXTRA_COMMAND_LINE, commandLine);
}
// Note, the intent may be saved and re-used by Android for re-launching the
// child service. Do not pass data that is different for each child; command
// line arguments for example.
if (mLinkerParams != null) {
mLinkerParams.addIntentExtras(intent);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment