Index: content/public/android/java/src/org/chromium/content/browser/ImportantChildProcessConnection.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/ImportantChildProcessConnection.java b/content/public/android/java/src/org/chromium/content/browser/ImportantChildProcessConnection.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b2f6d29e18a7867ce3db4acf963f23fcd6931bc6 |
--- /dev/null |
+++ b/content/public/android/java/src/org/chromium/content/browser/ImportantChildProcessConnection.java |
@@ -0,0 +1,61 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.content.browser; |
+ |
+import android.content.Context; |
+import android.os.Build; |
+import android.os.Bundle; |
+ |
+import org.chromium.base.VisibleForTesting; |
+import org.chromium.base.process_launcher.ChildProcessCreationParams; |
+ |
+/** |
+ * A connection that is bound as important, meaning the framework brings it to the foreground |
+ * process level when the app is. |
+ */ |
+public class ImportantChildProcessConnection extends BaseChildProcessConnection { |
+ public static final Factory FACTORY = new BaseChildProcessConnection.Factory() { |
+ @Override |
+ public BaseChildProcessConnection create(Context context, int number, boolean sandboxed, |
+ DeathCallback deathCallback, String serviceClassName, |
+ Bundle childProcessCommonParameters, ChildProcessCreationParams creationParams) { |
+ ImportantChildProcessConnection connection = |
+ new ImportantChildProcessConnection(context, number, sandboxed, deathCallback, |
+ serviceClassName, childProcessCommonParameters, creationParams); |
+ connection.initBinding(); |
+ return connection; |
+ } |
+ }; |
+ |
+ private ChildServiceConnection mBinding; |
+ |
+ private ImportantChildProcessConnection(Context context, int number, boolean sandboxed, |
+ DeathCallback deathCallback, String serviceClassName, |
+ Bundle childProcessCommonParameters, ChildProcessCreationParams creationParams) { |
+ super(context, number, sandboxed, deathCallback, serviceClassName, |
+ childProcessCommonParameters, creationParams); |
+ } |
+ |
+ @VisibleForTesting |
+ protected void initBinding() { |
boliu
2017/04/20 22:33:34
nothing actually overrides this?
Jay Civelli
2017/04/25 06:02:46
Removed @VisibleForTesting.
|
+ int flags = Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT; |
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && getCreationParams() != null |
+ && getCreationParams().getIsExternalService() |
+ && isExportedService(isSandboxed(), getContext(), getServiceName())) { |
+ flags |= Context.BIND_EXTERNAL_SERVICE; |
+ } |
+ mBinding = createServiceConnection(flags); |
+ } |
+ |
+ @Override |
+ public boolean bind() { |
+ return mBinding.bind(); |
+ } |
+ |
+ @Override |
+ public void unbind() { |
+ mBinding.unbind(); |
+ } |
+} |