Commit f7053a84 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

Remove ability to register multiple ChildProcessCreationParams objects part 2

This CL:
- Removes ChildProcessLauncherHelper#mCreationParams
- Moves public static ChildProcessCreationParams accessors from
  ChildProcessLauncherHelper.java to ChildProcessCreationParams.java
- Changes type of
  ChildProcessLauncherHelper#sSandboxedChildConnectionAllocatorMap
  from
    Map<String, ChildConnectionAllocator>
  to
    ChildConnectionAllocator
  (The map is no longer needed because WebAPKs no longer have special
   ChildProcessCreationParams)
- As there is now just one sandboxed ChildConnectionAllocator we now no
  longer free the allocator when the last connection is freed. This matches
  what we do for
  ChildProcessLauncherHelper#sPrivilegedChildConnectionAllocator

Deleted tests:
- Tested creating multiple allocators
  - testAllocatorForPackage()
  - testCustomCreationParamDoesNotReuseWarmupConnection() introduced in
    https://codereview.chromium.org/2705133002
- Tested that ChildConnectionAllocator is freed when last sandboxed connection
  was freed
  - testSandboxedAllocatorFreed() introduced in
    https://chromium-review.googlesource.com/c/chromium/src/+/513587
  - testSandboxedAllocatorFreedWith2Connections() introduced in
    https://chromium-review.googlesource.com/c/chromium/src/+/588380

BUG=797999

Change-Id: I2147ae24d99a7e8b2d93bb7f5a4a2b5ae37172f8
Reviewed-on: https://chromium-review.googlesource.com/884621
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarJay Civelli <jcivelli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532653}
parent 6d8c81c8
......@@ -6,6 +6,7 @@ package org.chromium.content.browser;
import android.os.Bundle;
import org.chromium.base.ContextUtils;
import org.chromium.base.library_loader.LibraryProcessType;
/**
......@@ -49,24 +50,29 @@ public class ChildProcessCreationParams {
mIgnoreVisibilityForImportance = ignoreVisibilityForImportance;
}
public String getPackageNameForSandboxedService() {
return mPackageNameForSandboxedService;
public void addIntentExtras(Bundle extras) {
extras.putInt(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType);
}
public boolean getIsSandboxedServiceExternal() {
return mIsSandboxedServiceExternal;
public static String getPackageNameForSandboxedService() {
ChildProcessCreationParams params = ChildProcessCreationParams.getDefault();
return params != null ? params.mPackageNameForSandboxedService
: ContextUtils.getApplicationContext().getPackageName();
}
public boolean getBindToCallerCheck() {
return mBindToCallerCheck;
public static boolean getIsSandboxedServiceExternal() {
ChildProcessCreationParams params = ChildProcessCreationParams.getDefault();
return params != null && params.mIsSandboxedServiceExternal;
}
public boolean getIgnoreVisibilityForImportance() {
return mIgnoreVisibilityForImportance;
public static boolean getBindToCallerCheck() {
ChildProcessCreationParams params = ChildProcessCreationParams.getDefault();
return params != null && params.mBindToCallerCheck;
}
public void addIntentExtras(Bundle extras) {
extras.putInt(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType);
public static boolean getIgnoreVisibilityForImportance() {
ChildProcessCreationParams params = ChildProcessCreationParams.getDefault();
return params != null && params.mIgnoreVisibilityForImportance;
}
public static int getLibraryProcessType(Bundle extras) {
......
......@@ -77,11 +77,11 @@ public class ChildProcessLauncherTestHelperService extends Service {
private void doBindService(final Message msg) {
String[] commandLine = { "_", "--" + BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER };
final boolean bindToCaller = true;
ChildProcessCreationParams params = new ChildProcessCreationParams(getPackageName(), false,
LibraryProcessType.PROCESS_CHILD, bindToCaller,
false /* ignoreVisibilityForImportance */);
ChildProcessCreationParams.registerDefault(new ChildProcessCreationParams(getPackageName(),
false, LibraryProcessType.PROCESS_CHILD, bindToCaller,
false /* ignoreVisibilityForImportance */));
mProcessLauncher = ChildProcessLauncherTestUtils.startForTesting(true /* sandboxed */,
commandLine, new FileDescriptorInfo[0], params, true /* doSetupConnection */);
commandLine, new FileDescriptorInfo[0], true /* doSetupConnection */);
// Poll the launcher until the connection is set up. The main test in
// ChildProcessLauncherTest, which has bound the connection to this service, manages the
......
......@@ -7,7 +7,6 @@ package org.chromium.content_shell_apk;
import org.chromium.base.process_launcher.ChildProcessConnection;
import org.chromium.base.process_launcher.FileDescriptorInfo;
import org.chromium.base.process_launcher.IChildProcessService;
import org.chromium.content.browser.ChildProcessCreationParams;
import org.chromium.content.browser.ChildProcessLauncherHelper;
import org.chromium.content.browser.LauncherThread;
......@@ -55,11 +54,11 @@ public final class ChildProcessLauncherTestUtils {
public static ChildProcessLauncherHelper startForTesting(final boolean sandboxed,
final String[] commandLine, final FileDescriptorInfo[] filesToBeMapped,
final ChildProcessCreationParams params, final boolean doSetupConnection) {
final boolean doSetupConnection) {
return runOnLauncherAndGetResult(new Callable<ChildProcessLauncherHelper>() {
@Override
public ChildProcessLauncherHelper call() {
return ChildProcessLauncherHelper.createAndStartForTesting(params, commandLine,
return ChildProcessLauncherHelper.createAndStartForTesting(commandLine,
filesToBeMapped, sandboxed, null /* binderCallback */, doSetupConnection);
}
});
......
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