| Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| index 611e2a1b81c96f222f83cac1d53ba8f24162b86b..df636694f45b4e868dcf8bf803d67968f1a5375b 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| @@ -222,40 +222,42 @@ public class ChildProcessLauncher {
|
| * Called when the renderer commits a navigation. This signals a time at which it is safe to
|
| * rely on renderer visibility signalled through setInForeground. See http://crbug.com/421041.
|
| */
|
| - public static void determinedVisibility(int pid) {
|
| - getBindingManager().determinedVisibility(pid);
|
| + public static void determinedVisibility(final int pid) {
|
| + assert ThreadUtils.runningOnUiThread();
|
| + LauncherThread.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + getBindingManager().onDeterminedVisibility(pid);
|
| + }
|
| + });
|
| }
|
|
|
| /**
|
| * Called when the embedding application is sent to background.
|
| */
|
| public static void onSentToBackground() {
|
| + assert ThreadUtils.runningOnUiThread();
|
| sApplicationInForeground = false;
|
| - getBindingManager().onSentToBackground();
|
| - }
|
| -
|
| - /**
|
| - * Starts moderate binding management.
|
| - * Note: WebAPKs and non WebAPKs share the same moderate binding pool, so the size of the
|
| - * shared moderate binding pool is always set based on the number of sandboxes processes
|
| - * used by Chrome.
|
| - * @param context Android's context.
|
| - * @param moderateBindingTillBackgrounded true if the BindingManager should add a moderate
|
| - * binding to a render process when it is created and remove the moderate binding when Chrome is
|
| - * sent to the background.
|
| - */
|
| - public static void startModerateBindingManagement(Context context) {
|
| - getBindingManager().startModerateBindingManagement(context,
|
| - ChildConnectionAllocator.getNumberOfServices(
|
| - context, true, context.getPackageName()));
|
| + LauncherThread.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + getBindingManager().onSentToBackground();
|
| + }
|
| + });
|
| }
|
|
|
| /**
|
| * Called when the embedding application is brought to foreground.
|
| */
|
| public static void onBroughtToForeground() {
|
| + assert ThreadUtils.runningOnUiThread();
|
| sApplicationInForeground = true;
|
| - getBindingManager().onBroughtToForeground();
|
| + LauncherThread.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + getBindingManager().onBroughtToForeground();
|
| + }
|
| + });
|
| }
|
|
|
| /**
|
| @@ -266,6 +268,28 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| /**
|
| + * Starts moderate binding management.
|
| + * Note: WebAPKs and non WebAPKs share the same moderate binding pool, so the size of the
|
| + * shared moderate binding pool is always set based on the number of sandboxes processes
|
| + * used by Chrome.
|
| + * @param context Android's context.
|
| + * @param moderateBindingTillBackgrounded true if the BindingManager should add a moderate
|
| + * binding to a render process when it is created and remove the moderate binding when Chrome is
|
| + * sent to the background.
|
| + */
|
| + public static void startModerateBindingManagement(final Context context) {
|
| + assert ThreadUtils.runningOnUiThread();
|
| + LauncherThread.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + getBindingManager().startModerateBindingManagement(context,
|
| + ChildConnectionAllocator.getNumberOfServices(
|
| + context, true, context.getPackageName()));
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| * Should be called early in startup so the work needed to spawn the child process can be done
|
| * in parallel to other startup work. Spare connection is created in sandboxed child process.
|
| * @param context the application context used for the connection.
|
| @@ -322,15 +346,14 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| /**
|
| - * Spawns and connects to a child process. May be called on any thread. It will not block, but
|
| - * will instead callback to {@link #nativeOnChildProcessStarted} when the connection is
|
| - * established. Note this callback will not necessarily be from the same thread (currently it
|
| - * always comes from the main thread).
|
| + * Spawns and connects to a child process. It will not block, but will instead callback to
|
| + * {@link #LaunchCallback} on the launcher thread when the connection is established on.
|
| *
|
| * @param context Context used to obtain the application context.
|
| * @param paramId Key used to retrieve ChildProcessCreationParams.
|
| * @param commandLine The child process command line argv.
|
| * @param filesToBeMapped File IDs, FDs, offsets, and lengths to pass through.
|
| + * @param launchCallback Callback invoked when the connection is established.
|
| */
|
| static void start(Context context, int paramId, final String[] commandLine, int childProcessId,
|
| FileDescriptorInfo[] filesToBeMapped, LaunchCallback launchCallback) {
|
| @@ -473,6 +496,7 @@ public class ChildProcessLauncher {
|
| new BaseChildProcessConnection.ConnectionCallback() {
|
| @Override
|
| public void onConnected(BaseChildProcessConnection connection) {
|
| + assert LauncherThread.runningOnLauncherThread();
|
| if (connection != null) {
|
| int pid = connection.getPid();
|
| Log.d(TAG, "on connect callback, pid=%d", pid);
|
|
|