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; ...@@ -6,7 +6,6 @@ package org.chromium.content.app;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
...@@ -48,20 +47,4 @@ public class ChildProcessService extends Service { ...@@ -48,20 +47,4 @@ public class ChildProcessService extends Service {
stopSelf(); stopSelf();
return mChildProcessServiceImpl.bind(intent, -1); 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 { ...@@ -70,8 +70,6 @@ public class ChildProcessServiceImpl {
private static AtomicReference<Context> sContext = new AtomicReference<>(null); private static AtomicReference<Context> sContext = new AtomicReference<>(null);
private boolean mLibraryInitialized = false; 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 * If >= 0 enables "validation of caller of {@link mBinder}'s methods". A RemoteException
...@@ -164,11 +162,7 @@ public class ChildProcessServiceImpl { ...@@ -164,11 +162,7 @@ public class ChildProcessServiceImpl {
Linker linker = null; Linker linker = null;
boolean requestedSharedRelro = false; boolean requestedSharedRelro = false;
if (Linker.isUsed()) { if (Linker.isUsed()) {
synchronized (mMainThread) { assert mLinkerParams != null;
while (!mIsBound) {
mMainThread.wait();
}
}
linker = getLinker(); linker = getLinker();
if (mLinkerParams.mWaitForSharedRelro) { if (mLinkerParams.mWaitForSharedRelro) {
requestedSharedRelro = true; requestedSharedRelro = true;
...@@ -282,28 +276,24 @@ public class ChildProcessServiceImpl { ...@@ -282,28 +276,24 @@ public class ChildProcessServiceImpl {
return mBinder; return mBinder;
} }
void initializeParams(Intent intent) { private void initializeParams(Intent intent) {
synchronized (mMainThread) { synchronized (mMainThread) {
mCommandLineParams =
intent.getStringArrayExtra(ChildProcessConstants.EXTRA_COMMAND_LINE);
// mLinkerParams is never used if Linker.isUsed() returns false. // mLinkerParams is never used if Linker.isUsed() returns false.
// See onCreate(). // See onCreate().
mLinkerParams = new ChromiumLinkerParams(intent); mLinkerParams = new ChromiumLinkerParams(intent);
mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent); mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent);
mIsBound = true;
mMainThread.notifyAll(); mMainThread.notifyAll();
} }
} }
void getServiceInfo(Bundle bundle) { private void getServiceInfo(Bundle bundle) {
// Required to unparcel FileDescriptorInfo. // Required to unparcel FileDescriptorInfo.
bundle.setClassLoader(mHostClassLoader); bundle.setClassLoader(mHostClassLoader);
synchronized (mMainThread) { 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) { if (mCommandLineParams == null) {
mCommandLineParams = mCommandLineParams =
bundle.getStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE); bundle.getStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE);
mMainThread.notifyAll();
} }
// We must have received the command line by now // We must have received the command line by now
assert mCommandLineParams != null; assert mCommandLineParams != null;
......
...@@ -130,9 +130,9 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { ...@@ -130,9 +130,9 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
try { try {
TraceEvent.begin("ChildProcessConnectionImpl.ChildServiceConnection.bind"); TraceEvent.begin("ChildProcessConnectionImpl.ChildServiceConnection.bind");
final Intent intent = createServiceBindIntent(); final Intent intent = createServiceBindIntent();
if (commandLine != null) { // Note, the intent may be saved and re-used by Android for re-launching the
intent.putExtra(ChildProcessConstants.EXTRA_COMMAND_LINE, commandLine); // child service. Do not pass data that is different for each child; command
} // line arguments for example.
if (mLinkerParams != null) { if (mLinkerParams != null) {
mLinkerParams.addIntentExtras(intent); 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