| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.app; | 5 package org.chromium.content.app; |
| 6 | 6 |
| 7 import android.app.Service; | 7 import android.app.Service; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.graphics.SurfaceTexture; | 10 import android.graphics.SurfaceTexture; |
| 11 import android.os.Bundle; | 11 import android.os.Bundle; |
| 12 import android.os.IBinder; | 12 import android.os.IBinder; |
| 13 import android.os.ParcelFileDescriptor; | 13 import android.os.ParcelFileDescriptor; |
| 14 import android.os.Process; | 14 import android.os.Process; |
| 15 import android.os.RemoteException; | 15 import android.os.RemoteException; |
| 16 import android.util.Log; | 16 import android.util.Log; |
| 17 import android.view.Surface; | 17 import android.view.Surface; |
| 18 | 18 |
| 19 import java.util.ArrayList; | 19 import java.util.ArrayList; |
| 20 | 20 |
| 21 import org.chromium.base.CalledByNative; | 21 import org.chromium.base.CalledByNative; |
| 22 import org.chromium.base.JNINamespace; | 22 import org.chromium.base.JNINamespace; |
| 23 import org.chromium.content.app.ContentMain; | 23 import org.chromium.content.app.ContentMain; |
| 24 import org.chromium.content.browser.SandboxedProcessConnection; | 24 import org.chromium.content.browser.SandboxedProcessConnection; |
| 25 import org.chromium.content.common.ISandboxedProcessCallback; | 25 import org.chromium.content.common.ISandboxedProcessCallback; |
| 26 import org.chromium.content.common.ISandboxedProcessService; | 26 import org.chromium.content.common.ISandboxedProcessService; |
| 27 import org.chromium.content.common.ProcessInitException; | 27 import org.chromium.content.common.ProcessInitException; |
| 28 import org.chromium.content.common.SurfaceCallback; | |
| 29 | 28 |
| 30 /** | 29 /** |
| 31 * This is the base class for sandboxed services; the SandboxedProcessService0,
1.. etc | 30 * This is the base class for sandboxed services; the SandboxedProcessService0,
1.. etc |
| 32 * subclasses provide the concrete service entry points, to enable the browser t
o connect | 31 * subclasses provide the concrete service entry points, to enable the browser t
o connect |
| 33 * to more than one distinct process (i.e. one process per service number, up to
limit of N). | 32 * to more than one distinct process (i.e. one process per service number, up to
limit of N). |
| 34 * The embedding application must declare these service instances in the applica
tion section | 33 * The embedding application must declare these service instances in the applica
tion section |
| 35 * of its AndroidManifest.xml, for example with N entries of the form:- | 34 * of its AndroidManifest.xml, for example with N entries of the form:- |
| 36 * <service android:name="org.chromium.content.app.SandboxedProcessServiceX" | 35 * <service android:name="org.chromium.content.app.SandboxedProcessServiceX" |
| 37 * android:process=":sandboxed_processX" /> | 36 * android:process=":sandboxed_processX" /> |
| 38 * for X in 0...N-1 (where N is {@link SandboxedProcessLauncher#MAX_REGISTERED_S
ERVICES}) | 37 * for X in 0...N-1 (where N is {@link SandboxedProcessLauncher#MAX_REGISTERED_S
ERVICES}) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 86 } |
| 88 mFileFds.add(parcel); | 87 mFileFds.add(parcel); |
| 89 String idName = SandboxedProcessConnection.EXTRA_FILES_PREFI
X + i | 88 String idName = SandboxedProcessConnection.EXTRA_FILES_PREFI
X + i |
| 90 + SandboxedProcessConnection.EXTRA_FILES_ID_SUFFIX; | 89 + SandboxedProcessConnection.EXTRA_FILES_ID_SUFFIX; |
| 91 mFileIds.add(args.getInt(idName)); | 90 mFileIds.add(args.getInt(idName)); |
| 92 } | 91 } |
| 93 mSandboxMainThread.notifyAll(); | 92 mSandboxMainThread.notifyAll(); |
| 94 } | 93 } |
| 95 return Process.myPid(); | 94 return Process.myPid(); |
| 96 } | 95 } |
| 97 | |
| 98 @Override | |
| 99 public void setSurface(int type, Surface surface, int primaryID, int sec
ondaryID) { | |
| 100 // This gives up ownership of the Surface. | |
| 101 SurfaceCallback.setSurface(type, surface, primaryID, secondaryID); | |
| 102 } | |
| 103 }; | 96 }; |
| 104 | 97 |
| 105 /* package */ static Context getContext() { | 98 /* package */ static Context getContext() { |
| 106 return sContext; | 99 return sContext; |
| 107 } | 100 } |
| 108 | 101 |
| 109 @Override | 102 @Override |
| 110 public void onCreate() { | 103 public void onCreate() { |
| 111 Log.i(TAG, "Creating new SandboxedProcessService pid=" + Process.myPid()
); | 104 Log.i(TAG, "Creating new SandboxedProcessService pid=" + Process.myPid()
); |
| 112 if (sContext != null) { | 105 if (sContext != null) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 SandboxedProcessService service, int[] extraFileIds, int[] extraFile
Fds, | 254 SandboxedProcessService service, int[] extraFileIds, int[] extraFile
Fds, |
| 262 int cpuCount, long cpuFeatures); | 255 int cpuCount, long cpuFeatures); |
| 263 | 256 |
| 264 /** | 257 /** |
| 265 * Force the sandboxed process to exit. | 258 * Force the sandboxed process to exit. |
| 266 */ | 259 */ |
| 267 private static native void nativeExitSandboxedProcess(); | 260 private static native void nativeExitSandboxedProcess(); |
| 268 | 261 |
| 269 private native void nativeShutdownSandboxMainThread(); | 262 private native void nativeShutdownSandboxMainThread(); |
| 270 } | 263 } |
| OLD | NEW |