| 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 d44163fa12cadfae7b9d276501a2452fb8b0e145..c4c5b9865c8e3cb5e308060a7d04f0e752924cef 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
|
| @@ -85,7 +85,8 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| public ChildProcessConnection allocate(
|
| - Context context, ChildProcessConnection.DeathCallback deathCallback,
|
| + Context context, int childProcessId,
|
| + ChildProcessConnection.DeathCallback deathCallback,
|
| ChromiumLinkerParams chromiumLinkerParams) {
|
| synchronized (mConnectionLock) {
|
| if (mFreeConnectionIndices.isEmpty()) {
|
| @@ -95,7 +96,8 @@ public class ChildProcessLauncher {
|
| int slot = mFreeConnectionIndices.remove(0);
|
| assert mChildProcessConnections[slot] == null;
|
| mChildProcessConnections[slot] = new ChildProcessConnectionImpl(context, slot,
|
| - mInSandbox, deathCallback, mChildClass, chromiumLinkerParams);
|
| + mInSandbox, childProcessId, deathCallback, mChildClass,
|
| + chromiumLinkerParams);
|
| return mChildProcessConnections[slot];
|
| }
|
| }
|
| @@ -145,7 +147,7 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| private static ChildProcessConnection allocateConnection(Context context,
|
| - boolean inSandbox, ChromiumLinkerParams chromiumLinkerParams) {
|
| + boolean inSandbox, int childProcessId, ChromiumLinkerParams chromiumLinkerParams) {
|
| ChildProcessConnection.DeathCallback deathCallback =
|
| new ChildProcessConnection.DeathCallback() {
|
| @Override
|
| @@ -154,7 +156,7 @@ public class ChildProcessLauncher {
|
| }
|
| };
|
| sConnectionAllocated = true;
|
| - return getConnectionAllocator(inSandbox).allocate(context, deathCallback,
|
| + return getConnectionAllocator(inSandbox).allocate(context, childProcessId, deathCallback,
|
| chromiumLinkerParams);
|
| }
|
|
|
| @@ -183,10 +185,10 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| private static ChildProcessConnection allocateBoundConnection(Context context,
|
| - String[] commandLine, boolean inSandbox) {
|
| + String[] commandLine, boolean inSandbox, int childProcessId) {
|
| ChromiumLinkerParams chromiumLinkerParams = getLinkerParamsForNewConnection();
|
| ChildProcessConnection connection =
|
| - allocateConnection(context, inSandbox, chromiumLinkerParams);
|
| + allocateConnection(context, inSandbox, childProcessId, chromiumLinkerParams);
|
| if (connection != null) {
|
| connection.start(commandLine);
|
| }
|
| @@ -268,7 +270,7 @@ public class ChildProcessLauncher {
|
| synchronized (ChildProcessLauncher.class) {
|
| assert !ThreadUtils.runningOnUiThread();
|
| if (sSpareSandboxedConnection == null) {
|
| - sSpareSandboxedConnection = allocateBoundConnection(context, null, true);
|
| + sSpareSandboxedConnection = allocateBoundConnection(context, null, true, 0);
|
| }
|
| }
|
| }
|
| @@ -305,6 +307,7 @@ public class ChildProcessLauncher {
|
| static void start(
|
| Context context,
|
| final String[] commandLine,
|
| + int childProcessId,
|
| int[] fileIds,
|
| int[] fileFds,
|
| boolean[] fileAutoClose,
|
| @@ -336,7 +339,8 @@ public class ChildProcessLauncher {
|
| }
|
| }
|
| if (allocatedConnection == null) {
|
| - allocatedConnection = allocateBoundConnection(context, commandLine, inSandbox);
|
| + allocatedConnection = allocateBoundConnection(context, commandLine, inSandbox,
|
| + childProcessId);
|
| if (allocatedConnection == null) {
|
| // Notify the native code so it can free the heap allocated callback.
|
| nativeOnChildProcessStarted(clientContext, 0);
|
| @@ -366,7 +370,7 @@ public class ChildProcessLauncher {
|
|
|
| connection.setupConnection(commandLine,
|
| filesToBeMapped,
|
| - createCallback(callbackType),
|
| + createCallback(childProcessId, callbackType),
|
| connectionCallback,
|
| Linker.getSharedRelros());
|
| }
|
| @@ -392,7 +396,8 @@ public class ChildProcessLauncher {
|
| /**
|
| * This implementation is used to receive callbacks from the remote service.
|
| */
|
| - private static IChildProcessCallback createCallback(final int callbackType) {
|
| + private static IChildProcessCallback createCallback(
|
| + final int childProcessId, final int callbackType) {
|
| return new IChildProcessCallback.Stub() {
|
| /**
|
| * This is called by the remote service regularly to tell us about new values. Note that
|
| @@ -423,6 +428,22 @@ public class ChildProcessLauncher {
|
|
|
| return nativeGetViewSurface(surfaceId);
|
| }
|
| +
|
| + @Override
|
| + public Surface getSurfaceTextureSurface(int primaryId, int secondaryId) {
|
| + if (callbackType != CALLBACK_FOR_RENDERER_PROCESS) {
|
| + Log.e(TAG, "Illegal callback for non-renderer process.");
|
| + return null;
|
| + }
|
| +
|
| + ChildProcessConnection connection = sServiceMap.get(secondaryId);
|
| + if (connection == null || connection.getChildProcessId() != childProcessId) {
|
| + Log.e(TAG, "Illegal secondaryId for renderer process.");
|
| + return null;
|
| + }
|
| +
|
| + return nativeGetSurfaceTextureSurface(primaryId, secondaryId);
|
| + }
|
| };
|
| }
|
|
|
| @@ -435,6 +456,7 @@ public class ChildProcessLauncher {
|
|
|
| private static native void nativeOnChildProcessStarted(long clientContext, int pid);
|
| private static native Surface nativeGetViewSurface(int surfaceId);
|
| + private static native Surface nativeGetSurfaceTextureSurface(int surfaceTextureId, int pid);
|
| private static native void nativeEstablishSurfacePeer(
|
| int pid, Surface surface, int primaryID, int secondaryID);
|
| private static native boolean nativeIsSingleProcess();
|
|
|