Upstream Context.BIND_EXTERNAL_SERVICE
BUG=592722 Review-Url: https://codereview.chromium.org/2464143004 Cr-Commit-Position: refs/heads/master@{#429642}
This commit is contained in:
android_webview
glue
java
src
com
android
webview
java
src
org
chromium
android_webview
chrome/android/java/src/org/chromium/chrome/browser/webapps
content/public/android
java
src
org
chromium
javatests
src
org
chromium
content
@ -400,8 +400,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
|
||||
setUpResources(webViewPackageName, context);
|
||||
initPlatSupportLibrary();
|
||||
initNetworkChangeNotifier(context);
|
||||
final int extraBindFlags = Context.BIND_EXTERNAL_SERVICE;
|
||||
AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, extraBindFlags);
|
||||
AwBrowserProcess.configureChildProcessLauncher(webViewPackageName);
|
||||
AwBrowserProcess.start();
|
||||
|
||||
if (isBuildDebuggable()) {
|
||||
|
@ -61,9 +61,9 @@ public abstract class AwBrowserProcess {
|
||||
* Configures child process launcher. This is required only if child services are used in
|
||||
* WebView.
|
||||
*/
|
||||
public static void configureChildProcessLauncher(String packageName, int extraBindFlags) {
|
||||
public static void configureChildProcessLauncher(String packageName) {
|
||||
ChildProcessCreationParams.set(
|
||||
new ChildProcessCreationParams(packageName, extraBindFlags,
|
||||
new ChildProcessCreationParams(packageName,
|
||||
LibraryProcessType.PROCESS_WEBVIEW_CHILD));
|
||||
}
|
||||
|
||||
|
@ -162,9 +162,8 @@ public class WebApkActivity extends WebappActivity {
|
||||
ChromeApplication chrome = (ChromeApplication) ContextUtils.getApplicationContext();
|
||||
ChildProcessCreationParams params = chrome.getChildProcessCreationParams();
|
||||
if (isForWebApk) {
|
||||
int extraBindFlag = params == null ? 0 : params.getExtraBindFlags();
|
||||
params = new ChildProcessCreationParams(getWebappInfo().webApkPackageName(),
|
||||
extraBindFlag, LibraryProcessType.PROCESS_CHILD);
|
||||
LibraryProcessType.PROCESS_CHILD);
|
||||
}
|
||||
ChildProcessCreationParams.set(params);
|
||||
}
|
||||
|
@ -120,10 +120,7 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public ChildServiceConnection(int bindFlags, boolean needsExtraBindFlags) {
|
||||
if (needsExtraBindFlags && mCreationParams != null) {
|
||||
bindFlags = mCreationParams.addExtraBindFlags(bindFlags);
|
||||
}
|
||||
public ChildServiceConnection(int bindFlags) {
|
||||
mBindFlags = bindFlags;
|
||||
}
|
||||
|
||||
@ -226,16 +223,17 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
|
||||
mCreationParams = creationParams;
|
||||
int initialFlags = Context.BIND_AUTO_CREATE;
|
||||
if (mAlwaysInForeground) initialFlags |= Context.BIND_IMPORTANT;
|
||||
// "external service" attribute is approximated by "exported" attribute.
|
||||
// TODO(mnaganov): Update after the release of the next Android SDK.
|
||||
final boolean needsExtraBindFlags = isExportedService(inSandbox, mContext, mServiceName);
|
||||
mInitialBinding = new ChildServiceConnection(initialFlags, needsExtraBindFlags);
|
||||
int extralBindFlags = 0;
|
||||
if (isExportedService(inSandbox, mContext, mServiceName)) {
|
||||
extralBindFlags = Context.BIND_EXTERNAL_SERVICE;
|
||||
}
|
||||
mInitialBinding = new ChildServiceConnection(initialFlags | extralBindFlags);
|
||||
mStrongBinding = new ChildServiceConnection(
|
||||
Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT, needsExtraBindFlags);
|
||||
Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT | extralBindFlags);
|
||||
mWaivedBinding = new ChildServiceConnection(
|
||||
Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY, needsExtraBindFlags);
|
||||
Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY | extralBindFlags);
|
||||
mModerateBinding = new ChildServiceConnection(
|
||||
Context.BIND_AUTO_CREATE, needsExtraBindFlags);
|
||||
Context.BIND_AUTO_CREATE | extralBindFlags);
|
||||
}
|
||||
|
||||
private static boolean isExportedService(boolean inSandbox, Context context,
|
||||
|
@ -11,12 +11,10 @@ import org.chromium.base.library_loader.LibraryProcessType;
|
||||
/**
|
||||
* Allows specifying the package name for looking up child services
|
||||
* configuration and classes into (if it differs from the application
|
||||
* package name, like in the case of Android WebView). Also allows
|
||||
* specifying additional child service binging flags.
|
||||
* package name, like in the case of Android WebView).
|
||||
*/
|
||||
public class ChildProcessCreationParams {
|
||||
private final String mPackageName;
|
||||
private final int mExtraBindFlags;
|
||||
private final int mLibraryProcessType;
|
||||
private static final String EXTRA_LIBRARY_PROCESS_TYPE =
|
||||
"org.chromium.content.common.child_service_params.library_process_type";
|
||||
@ -31,40 +29,23 @@ public class ChildProcessCreationParams {
|
||||
return sChildProcessCreationParams;
|
||||
}
|
||||
|
||||
public ChildProcessCreationParams(String packageName, int extraBindFlags,
|
||||
int libraryProcessType) {
|
||||
public ChildProcessCreationParams(String packageName, int libraryProcessType) {
|
||||
mPackageName = packageName;
|
||||
mExtraBindFlags = extraBindFlags;
|
||||
mLibraryProcessType = libraryProcessType;
|
||||
}
|
||||
|
||||
public ChildProcessCreationParams copy() {
|
||||
return new ChildProcessCreationParams(mPackageName, mExtraBindFlags, mLibraryProcessType);
|
||||
return new ChildProcessCreationParams(mPackageName, mLibraryProcessType);
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
public int getExtraBindFlags() {
|
||||
return mExtraBindFlags;
|
||||
}
|
||||
|
||||
public int getLibraryProcessType() {
|
||||
return mLibraryProcessType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds required extra flags to the given child service binding flags and returns them.
|
||||
* Does not modify the state of the ChildProcessCreationParams instance.
|
||||
*
|
||||
* @param bindFlags Source bind flags to modify.
|
||||
* @return Bind flags with extra flags added.
|
||||
*/
|
||||
public int addExtraBindFlags(int bindFlags) {
|
||||
return bindFlags | mExtraBindFlags;
|
||||
}
|
||||
|
||||
public void addIntentExtras(Intent intent) {
|
||||
intent.putExtra(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType);
|
||||
}
|
||||
|
@ -680,10 +680,8 @@ public class ChildProcessLauncher {
|
||||
// name. In WebAPK, ChildProcessCreationParams are initialized with WebAPK's
|
||||
// package name. Make a copy of the WebAPK's params, but replace the package with
|
||||
// Chrome's package to use when initializing a non-renderer processes.
|
||||
// TODO(michaelbai | hanxi): crbug.com/620102. Cleans up the setting of
|
||||
// ChildProcessCreationParams after using N sdk.
|
||||
params = new ChildProcessCreationParams(context.getPackageName(),
|
||||
params.getExtraBindFlags(), params.getLibraryProcessType());
|
||||
params.getLibraryProcessType());
|
||||
}
|
||||
if (ContentSwitches.SWITCH_GPU_PROCESS.equals(processType)) {
|
||||
callbackType = CALLBACK_FOR_GPU_PROCESS;
|
||||
|
@ -336,8 +336,7 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
private ChildProcessCreationParams getDefaultChildProcessCreationParams(String packageName) {
|
||||
return new ChildProcessCreationParams(packageName, 0,
|
||||
LibraryProcessType.PROCESS_CHILD);
|
||||
return new ChildProcessCreationParams(packageName, LibraryProcessType.PROCESS_CHILD);
|
||||
}
|
||||
|
||||
private void triggerConnectionSetup(ChildProcessConnectionImpl connection) {
|
||||
|
Reference in New Issue
Block a user