OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.ComponentName; | 7 import android.content.ComponentName; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.pm.ApplicationInfo; | 9 import android.content.pm.ApplicationInfo; |
10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
11 import android.os.AsyncTask; | 11 import android.os.AsyncTask; |
12 import android.os.Bundle; | 12 import android.os.Bundle; |
| 13 import android.os.IBinder; |
13 import android.os.ParcelFileDescriptor; | 14 import android.os.ParcelFileDescriptor; |
14 import android.os.RemoteException; | 15 import android.os.RemoteException; |
15 import android.text.TextUtils; | 16 import android.text.TextUtils; |
16 import android.view.Surface; | |
17 | 17 |
18 import org.chromium.base.CommandLine; | 18 import org.chromium.base.CommandLine; |
19 import org.chromium.base.CpuFeatures; | 19 import org.chromium.base.CpuFeatures; |
20 import org.chromium.base.Log; | 20 import org.chromium.base.Log; |
21 import org.chromium.base.ThreadUtils; | 21 import org.chromium.base.ThreadUtils; |
22 import org.chromium.base.TraceEvent; | 22 import org.chromium.base.TraceEvent; |
23 import org.chromium.base.UnguessableToken; | |
24 import org.chromium.base.VisibleForTesting; | 23 import org.chromium.base.VisibleForTesting; |
25 import org.chromium.base.annotations.CalledByNative; | 24 import org.chromium.base.annotations.CalledByNative; |
26 import org.chromium.base.annotations.JNINamespace; | 25 import org.chromium.base.annotations.JNINamespace; |
27 import org.chromium.base.library_loader.Linker; | 26 import org.chromium.base.library_loader.Linker; |
28 import org.chromium.base.process_launcher.ChildProcessCreationParams; | 27 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
29 import org.chromium.base.process_launcher.FileDescriptorInfo; | 28 import org.chromium.base.process_launcher.FileDescriptorInfo; |
30 import org.chromium.content.app.ChromiumLinkerParams; | 29 import org.chromium.content.app.ChromiumLinkerParams; |
31 import org.chromium.content.app.PrivilegedProcessService; | 30 import org.chromium.content.app.PrivilegedProcessService; |
32 import org.chromium.content.app.SandboxedProcessService; | 31 import org.chromium.content.app.SandboxedProcessService; |
33 import org.chromium.content.common.ContentSwitches; | 32 import org.chromium.content.common.ContentSwitches; |
34 import org.chromium.content.common.IChildProcessCallback; | |
35 import org.chromium.content.common.SurfaceWrapper; | |
36 | 33 |
37 import java.io.IOException; | 34 import java.io.IOException; |
38 import java.util.ArrayList; | 35 import java.util.ArrayList; |
39 import java.util.LinkedList; | 36 import java.util.LinkedList; |
40 import java.util.Map; | 37 import java.util.Map; |
41 import java.util.Queue; | 38 import java.util.Queue; |
42 import java.util.concurrent.ConcurrentHashMap; | 39 import java.util.concurrent.ConcurrentHashMap; |
43 | 40 |
44 /** | 41 /** |
45 * This class provides the method to start/stop ChildProcess called by native. | 42 * This class provides the method to start/stop ChildProcess called by native. |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return; | 818 return; |
822 } | 819 } |
823 sBindingManager.clearConnection(pid); | 820 sBindingManager.clearConnection(pid); |
824 connection.stop(); | 821 connection.stop(); |
825 freeConnection(connection); | 822 freeConnection(connection); |
826 } | 823 } |
827 | 824 |
828 /** | 825 /** |
829 * This implementation is used to receive callbacks from the remote service. | 826 * This implementation is used to receive callbacks from the remote service. |
830 */ | 827 */ |
831 private static IChildProcessCallback createCallback( | 828 private static IBinder createCallback(int childProcessId, int callbackType)
{ |
832 final int childProcessId, final int callbackType) { | 829 return callbackType == CALLBACK_FOR_GPU_PROCESS ? new GpuProcessCallback
() : null; |
833 return new IChildProcessCallback.Stub() { | |
834 @Override | |
835 public void forwardSurfaceForSurfaceRequest( | |
836 UnguessableToken requestToken, Surface surface) { | |
837 // Do not allow a malicious renderer to connect to a producer. T
his is only used | |
838 // from stream textures managed by the GPU process. | |
839 if (callbackType != CALLBACK_FOR_GPU_PROCESS) { | |
840 Log.e(TAG, "Illegal callback for non-GPU process."); | |
841 return; | |
842 } | |
843 | |
844 nativeCompleteScopedSurfaceRequest(requestToken, surface); | |
845 } | |
846 | |
847 @Override | |
848 public SurfaceWrapper getViewSurface(int surfaceId) { | |
849 // Do not allow a malicious renderer to get to our view surface. | |
850 if (callbackType != CALLBACK_FOR_GPU_PROCESS) { | |
851 Log.e(TAG, "Illegal callback for non-GPU process."); | |
852 return null; | |
853 } | |
854 Surface surface = ChildProcessLauncher.nativeGetViewSurface(surf
aceId); | |
855 if (surface == null) { | |
856 return null; | |
857 } | |
858 return new SurfaceWrapper(surface); | |
859 } | |
860 }; | |
861 } | 830 } |
862 | 831 |
863 static void logPidWarning(int pid, String message) { | 832 static void logPidWarning(int pid, String message) { |
864 // This class is effectively a no-op in single process mode, so don't lo
g warnings there. | 833 // This class is effectively a no-op in single process mode, so don't lo
g warnings there. |
865 if (pid > 0 && !nativeIsSingleProcess()) { | 834 if (pid > 0 && !nativeIsSingleProcess()) { |
866 Log.w(TAG, "%s, pid=%d", message, pid); | 835 Log.w(TAG, "%s, pid=%d", message, pid); |
867 } | 836 } |
868 } | 837 } |
869 | 838 |
870 @VisibleForTesting | 839 @VisibleForTesting |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 try { | 931 try { |
963 ((ChildProcessConnectionImpl) sServiceMap.get(pid)).crashServiceForT
esting(); | 932 ((ChildProcessConnectionImpl) sServiceMap.get(pid)).crashServiceForT
esting(); |
964 } catch (RemoteException ex) { | 933 } catch (RemoteException ex) { |
965 return false; | 934 return false; |
966 } | 935 } |
967 | 936 |
968 return true; | 937 return true; |
969 } | 938 } |
970 | 939 |
971 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); | 940 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); |
972 private static native void nativeCompleteScopedSurfaceRequest( | |
973 UnguessableToken requestToken, Surface surface); | |
974 private static native boolean nativeIsSingleProcess(); | 941 private static native boolean nativeIsSingleProcess(); |
975 private static native Surface nativeGetViewSurface(int surfaceId); | |
976 } | 942 } |
OLD | NEW |