| Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
|
| index ecbafeff7589a90e92d9dd9b02755b090328e1ae..710741b69c86a045512bf88f0459e6b9fd7934e7 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
|
| @@ -159,61 +159,15 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
|
| }
|
|
|
| @Override
|
| - public void onServiceConnected(ComponentName className, IBinder service) {
|
| - synchronized (mLock) {
|
| - // A flag from the parent class ensures we run the post-connection logic only once
|
| - // (instead of once per each ChildServiceConnection).
|
| - if (mDidOnServiceConnected) {
|
| - return;
|
| - }
|
| - try {
|
| - TraceEvent.begin(
|
| - "ChildProcessConnectionImpl.ChildServiceConnection.onServiceConnected");
|
| - mDidOnServiceConnected = true;
|
| - mService = IChildProcessService.Stub.asInterface(service);
|
| -
|
| - StartCallback startCallback = mStartCallback;
|
| - mStartCallback = null;
|
| -
|
| - final boolean bindCheck =
|
| - mCreationParams != null && mCreationParams.getBindToCallerCheck();
|
| - boolean boundToUs = false;
|
| - try {
|
| - boundToUs = bindCheck ? mService.bindToCaller() : true;
|
| - } catch (RemoteException ex) {
|
| - // Do not trigger the StartCallback here, since the service is already
|
| - // dead and the DeathCallback will run from onServiceDisconnected().
|
| - Log.e(TAG, "Failed to bind service to connection.", ex);
|
| - return;
|
| - }
|
| -
|
| - if (startCallback != null) {
|
| - if (boundToUs) {
|
| - startCallback.onChildStarted();
|
| - } else {
|
| - startCallback.onChildStartFailed();
|
| - }
|
| - }
|
| -
|
| - if (!boundToUs) {
|
| - return;
|
| - }
|
| -
|
| - mServiceConnectComplete = true;
|
| -
|
| - // Run the setup if the connection parameters have already been provided. If
|
| - // not, doConnectionSetupLocked() will be called from setupConnection().
|
| - if (mConnectionParams != null) {
|
| - doConnectionSetupLocked();
|
| - }
|
| - } finally {
|
| - TraceEvent.end(
|
| - "ChildProcessConnectionImpl.ChildServiceConnection.onServiceConnected");
|
| + public void onServiceConnected(ComponentName className, final IBinder service) {
|
| + LauncherThread.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + ChildProcessConnectionImpl.this.onServiceConnectedOnLauncherThread(service);
|
| }
|
| - }
|
| + });
|
| }
|
|
|
| -
|
| // Called on the main thread to notify that the child service did not disconnect gracefully.
|
| @Override
|
| public void onServiceDisconnected(ComponentName className) {
|
| @@ -339,6 +293,7 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
|
| @Override
|
| public void setupConnection(String[] commandLine, FileDescriptorInfo[] filesToBeMapped,
|
| @Nullable IBinder callback, ConnectionCallback connectionCallback) {
|
| + assert LauncherThread.runningOnLauncherThread();
|
| synchronized (mLock) {
|
| assert mConnectionParams == null;
|
| if (mServiceDisconnected) {
|
| @@ -376,6 +331,61 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
|
| }
|
| }
|
|
|
| + private void onServiceConnectedOnLauncherThread(IBinder service) {
|
| + assert LauncherThread.runningOnLauncherThread();
|
| + synchronized (mLock) {
|
| + // A flag from the parent class ensures we run the post-connection logic only once
|
| + // (instead of once per each ChildServiceConnection).
|
| + if (mDidOnServiceConnected) {
|
| + return;
|
| + }
|
| + try {
|
| + TraceEvent.begin(
|
| + "ChildProcessConnectionImpl.ChildServiceConnection.onServiceConnected");
|
| + mDidOnServiceConnected = true;
|
| + mService = IChildProcessService.Stub.asInterface(service);
|
| +
|
| + StartCallback startCallback = mStartCallback;
|
| + mStartCallback = null;
|
| +
|
| + final boolean bindCheck =
|
| + mCreationParams != null && mCreationParams.getBindToCallerCheck();
|
| + boolean boundToUs = false;
|
| + try {
|
| + boundToUs = bindCheck ? mService.bindToCaller() : true;
|
| + } catch (RemoteException ex) {
|
| + // Do not trigger the StartCallback here, since the service is already
|
| + // dead and the DeathCallback will run from onServiceDisconnected().
|
| + Log.e(TAG, "Failed to bind service to connection.", ex);
|
| + return;
|
| + }
|
| +
|
| + if (startCallback != null) {
|
| + if (boundToUs) {
|
| + startCallback.onChildStarted();
|
| + } else {
|
| + startCallback.onChildStartFailed();
|
| + }
|
| + }
|
| +
|
| + if (!boundToUs) {
|
| + return;
|
| + }
|
| +
|
| + mServiceConnectComplete = true;
|
| +
|
| + // Run the setup if the connection parameters have already been provided. If
|
| + // not, doConnectionSetupLocked() will be called from setupConnection().
|
| + if (mConnectionParams != null) {
|
| + doConnectionSetupLocked();
|
| + }
|
| + } finally {
|
| + TraceEvent.end(
|
| + "ChildProcessConnectionImpl.ChildServiceConnection.onServiceConnected");
|
| + }
|
| + }
|
| + }
|
| +
|
| private void onServiceDisconnectedOnLauncherThread() {
|
| assert LauncherThread.runningOnLauncherThread();
|
| synchronized (mLock) {
|
|
|