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; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } | 758 } |
759 } | 759 } |
760 | 760 |
761 /** | 761 /** |
762 * Create the common bundle to be passed to child processes. | 762 * Create the common bundle to be passed to child processes. |
763 * @param context Application context. | 763 * @param context Application context. |
764 * @param commandLine Command line params to be passed to the service. | 764 * @param commandLine Command line params to be passed to the service. |
765 * @param linkerParams Linker params to start the service. | 765 * @param linkerParams Linker params to start the service. |
766 */ | 766 */ |
767 protected static Bundle createsServiceBundle( | 767 protected static Bundle createsServiceBundle( |
768 String[] commandLine, FileDescriptorInfo[] filesToBeMapped, Bundle s
haredRelros) { | 768 String[] commandLine, FileDescriptorInfo[] filesToBeMapped) { |
769 Bundle bundle = new Bundle(); | 769 Bundle bundle = new Bundle(); |
770 bundle.putStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE, commandL
ine); | 770 bundle.putStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE, commandL
ine); |
771 bundle.putParcelableArray(ChildProcessConstants.EXTRA_FILES, filesToBeMa
pped); | 771 bundle.putParcelableArray(ChildProcessConstants.EXTRA_FILES, filesToBeMa
pped); |
772 bundle.putInt(ChildProcessConstants.EXTRA_CPU_COUNT, CpuFeatures.getCoun
t()); | 772 bundle.putInt(ChildProcessConstants.EXTRA_CPU_COUNT, CpuFeatures.getCoun
t()); |
773 bundle.putLong(ChildProcessConstants.EXTRA_CPU_FEATURES, CpuFeatures.get
Mask()); | 773 bundle.putLong(ChildProcessConstants.EXTRA_CPU_FEATURES, CpuFeatures.get
Mask()); |
774 bundle.putBundle(Linker.EXTRA_LINKER_SHARED_RELROS, sharedRelros); | 774 bundle.putBundle(Linker.EXTRA_LINKER_SHARED_RELROS, Linker.getInstance()
.getSharedRelros()); |
775 return bundle; | 775 return bundle; |
776 } | 776 } |
777 | 777 |
778 @VisibleForTesting | 778 @VisibleForTesting |
779 static void triggerConnectionSetup( | 779 static void triggerConnectionSetup( |
780 final ChildProcessConnection connection, | 780 final ChildProcessConnection connection, |
781 String[] commandLine, | 781 String[] commandLine, |
782 int childProcessId, | 782 int childProcessId, |
783 FileDescriptorInfo[] filesToBeMapped, | 783 FileDescriptorInfo[] filesToBeMapped, |
784 final int callbackType, | 784 final int callbackType, |
(...skipping 11 matching lines...) Expand all Loading... |
796 // If the connection fails and pid == 0, the Java-side c
leanup was already | 796 // If the connection fails and pid == 0, the Java-side c
leanup was already |
797 // handled by DeathCallback. We still have to call back
to native for | 797 // handled by DeathCallback. We still have to call back
to native for |
798 // cleanup there. | 798 // cleanup there. |
799 if (clientContext != 0) { // Will be 0 in Java instrume
ntation tests. | 799 if (clientContext != 0) { // Will be 0 in Java instrume
ntation tests. |
800 nativeOnChildProcessStarted(clientContext, pid); | 800 nativeOnChildProcessStarted(clientContext, pid); |
801 } | 801 } |
802 } | 802 } |
803 }; | 803 }; |
804 | 804 |
805 assert callbackType != CALLBACK_FOR_UNKNOWN_PROCESS; | 805 assert callbackType != CALLBACK_FOR_UNKNOWN_PROCESS; |
806 connection.setupConnection(commandLine, | 806 connection.setupConnection(commandLine, filesToBeMapped, |
807 filesToBeMapped, | 807 createCallback(childProcessId, callbackType), connectionCallback
); |
808 createCallback(childProcessId, callbackType), | |
809 connectionCallback, | |
810 Linker.getInstance().getSharedRelros()); | |
811 } | 808 } |
812 | 809 |
813 /** | 810 /** |
814 * Terminates a child process. This may be called from any thread. | 811 * Terminates a child process. This may be called from any thread. |
815 * | 812 * |
816 * @param pid The pid (process handle) of the service connection obtained fr
om {@link #start}. | 813 * @param pid The pid (process handle) of the service connection obtained fr
om {@link #start}. |
817 */ | 814 */ |
818 @CalledByNative | 815 @CalledByNative |
819 static void stop(int pid) { | 816 static void stop(int pid) { |
820 Log.d(TAG, "stopping child connection: pid=%d", pid); | 817 Log.d(TAG, "stopping child connection: pid=%d", pid); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 967 |
971 return true; | 968 return true; |
972 } | 969 } |
973 | 970 |
974 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); | 971 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); |
975 private static native void nativeCompleteScopedSurfaceRequest( | 972 private static native void nativeCompleteScopedSurfaceRequest( |
976 UnguessableToken requestToken, Surface surface); | 973 UnguessableToken requestToken, Surface surface); |
977 private static native boolean nativeIsSingleProcess(); | 974 private static native boolean nativeIsSingleProcess(); |
978 private static native Surface nativeGetViewSurface(int surfaceId); | 975 private static native Surface nativeGetViewSurface(int surfaceId); |
979 } | 976 } |
OLD | NEW |