Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: content/public/android/java/src/org/chromium/content/app/ChildProcessService.java

Issue 1156873002: Load v8 snapshots directly from APK (and store them uncompressed) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8initializer
Patch Set: Pass FDs & Regions through to child process (Still has formatting errors) Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
diff --git a/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java b/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
index d25ac652e7ba8474a3b459aae660b431935d3dd5..b452e113088b4b1d1bfee17be1bfd5270ba4f643 100644
--- a/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
+++ b/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
@@ -10,7 +10,7 @@ import android.content.Intent;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
@@ -27,10 +27,11 @@ import org.chromium.base.library_loader.Linker;
import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.content.browser.ChildProcessConnection;
import org.chromium.content.browser.ChildProcessLauncher;
+import org.chromium.content.browser.FileDescriptorInfo;
import org.chromium.content.common.IChildProcessCallback;
import org.chromium.content.common.IChildProcessService;
-import java.util.ArrayList;
+import java.io.FileDescriptor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicReference;
@@ -57,8 +58,7 @@ public class ChildProcessService extends Service {
private int mCpuCount;
private long mCpuFeatures;
// Pairs IDs and file descriptors that should be registered natively.
- private ArrayList<Integer> mFileIds;
- private ArrayList<ParcelFileDescriptor> mFileFds;
+ private FileDescriptorInfo[] mFdInfos;
// Linker-specific parameters for this child process service.
private ChromiumLinkerParams mLinkerParams;
@@ -74,7 +74,10 @@ public class ChildProcessService extends Service {
// NOTE: Implement any IChildProcessService methods here.
@Override
public int setupConnection(Bundle args, IChildProcessCallback callback) {
+ Log.w("ANDREW", "setupConnection" );
mCallback = callback;
+ // Required to unparcel FileDescriptorInfo.
+ args.setClassLoader(getClassLoader());
synchronized (mMainThread) {
// Allow the command line to be set via bind() intent or setupConnection, but
// the FD can only be transferred here.
@@ -87,21 +90,11 @@ public class ChildProcessService extends Service {
mCpuCount = args.getInt(ChildProcessConnection.EXTRA_CPU_COUNT);
mCpuFeatures = args.getLong(ChildProcessConnection.EXTRA_CPU_FEATURES);
assert mCpuCount > 0;
- mFileIds = new ArrayList<Integer>();
- mFileFds = new ArrayList<ParcelFileDescriptor>();
- for (int i = 0;; i++) {
- String fdName = ChildProcessConnection.EXTRA_FILES_PREFIX + i
- + ChildProcessConnection.EXTRA_FILES_FD_SUFFIX;
- ParcelFileDescriptor parcel = args.getParcelable(fdName);
- if (parcel == null) {
- // End of the file list.
- break;
- }
- mFileFds.add(parcel);
- String idName = ChildProcessConnection.EXTRA_FILES_PREFIX + i
- + ChildProcessConnection.EXTRA_FILES_ID_SUFFIX;
- mFileIds.add(args.getInt(idName));
- }
+ Parcelable[] fdInfosAsParcelable = args.getParcelableArray(
+ ChildProcessConnection.EXTRA_FILES);
+ mFdInfos = new FileDescriptorInfo[fdInfosAsParcelable.length];
+ System.arraycopy(fdInfosAsParcelable, 0, mFdInfos, 0, fdInfosAsParcelable.length);
+ Log.w("ANDREW", "Got FDs: " + fdInfosAsParcelable.length );
Bundle sharedRelros = args.getBundle(Linker.EXTRA_LINKER_SHARED_RELROS);
if (sharedRelros != null) {
Linker.useSharedRelros(sharedRelros);
@@ -125,6 +118,7 @@ public class ChildProcessService extends Service {
@Override
public void onCreate() {
Log.i(TAG, "Creating new ChildProcessService pid=" + Process.myPid());
+ Log.i("ANDREW", "asdfasdfsadfce pid=" + Process.myPid());
if (sContext.get() != null) {
throw new RuntimeException("Illegal child process reuse.");
}
@@ -201,21 +195,20 @@ public class ChildProcessService extends Service {
synchronized (mMainThread) {
mLibraryInitialized = true;
mMainThread.notifyAll();
- while (mFileIds == null) {
+ while (mFdInfos == null) {
mMainThread.wait();
}
}
- assert mFileIds.size() == mFileFds.size();
- int[] fileIds = new int[mFileIds.size()];
- int[] fileFds = new int[mFileFds.size()];
- for (int i = 0; i < mFileIds.size(); ++i) {
- fileIds[i] = mFileIds.get(i);
- fileFds[i] = mFileFds.get(i).detachFd();
- }
ContentMain.initApplicationContext(sContext.get().getApplicationContext());
+ Log.w("ANDREW", "start " + mFdInfos);
+ for (FileDescriptorInfo fdInfo : mFdInfos) {
+ Log.w("ANDREW", "REG: " + fdInfo.mId + " " + fdInfo.mFd);
+ nativeRegisterGlobalFileDescriptor(fdInfo.mId, fdInfo.mFd.detachFd(),
+ fdInfo.mOffset, fdInfo.mSize);
+ }
+ Log.w("ANDREW", "DONE");
nativeInitChildProcess(sContext.get().getApplicationContext(),
- ChildProcessService.this, fileIds, fileFds,
- mCpuCount, mCpuFeatures);
+ ChildProcessService.this, mCpuCount, mCpuFeatures);
if (mActivitySemaphore.tryAcquire()) {
ContentMain.start();
nativeExitChildProcess();
@@ -285,7 +278,7 @@ public class ChildProcessService extends Service {
* Through using the callback object the browser is used as a proxy to route the
* call to the correct process.
*
- * @param pid Process handle of the child process to share the SurfaceTexture with.
+ * @param pid Process handle of the cmIsBounhild process to share the SurfaceTexture with.
* @param surfaceObject The Surface or SurfaceTexture to share with the other child process.
* @param primaryID Used to route the call to the correct client instance.
* @param secondaryID Used to route the call to the correct client instance.
@@ -388,18 +381,23 @@ public class ChildProcessService extends Service {
}
/**
+ * Helper for registering FileDescriptorInfo objects with GlobalFileDescriptors.
+ * This includes the IPC channel, the crash dump signals and resource related
+ * files.
+ */
+ private static native void nativeRegisterGlobalFileDescriptor(
+ int id, int fd, long offset, long size);
+
+ /**
* The main entry point for a child process. This should be called from a new thread since
* it will not return until the child process exits. See child_process_service.{h,cc}
*
* @param applicationContext The Application Context of the current process.
* @param service The current ChildProcessService object.
- * @param fileIds A list of file IDs that should be registered for access by the renderer.
- * @param fileFds A list of file descriptors that should be registered for access by the
* renderer.
*/
private static native void nativeInitChildProcess(Context applicationContext,
- ChildProcessService service, int[] extraFileIds, int[] extraFileFds,
- int cpuCount, long cpuFeatures);
+ ChildProcessService service, int cpuCount, long cpuFeatures);
/**
* Force the child process to exit.

Powered by Google App Engine
This is Rietveld 408576698