OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.Context; | 7 import android.content.Context; |
8 import android.os.ParcelFileDescriptor; | 8 import android.os.ParcelFileDescriptor; |
9 | 9 |
| 10 import org.chromium.base.ContextUtils; |
10 import org.chromium.base.Log; | 11 import org.chromium.base.Log; |
11 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
12 import org.chromium.base.annotations.JNINamespace; | 13 import org.chromium.base.annotations.JNINamespace; |
| 14 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
13 import org.chromium.base.process_launcher.FileDescriptorInfo; | 15 import org.chromium.base.process_launcher.FileDescriptorInfo; |
14 | 16 |
15 import java.io.IOException; | 17 import java.io.IOException; |
16 | 18 |
17 /** | 19 /** |
18 * This is the java counterpart to ChildProcessLauncherHelper. It is owned by na
tive side and | 20 * This is the java counterpart to ChildProcessLauncherHelper. It is owned by na
tive side and |
19 * has an explicit destroy method. | 21 * has an explicit destroy method. |
20 * Each public or jni methods should have explicit documentation on what threads
they are called. | 22 * Each public or jni methods should have explicit documentation on what threads
they are called. |
21 */ | 23 */ |
22 @JNINamespace("content::internal") | 24 @JNINamespace("content::internal") |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 private void setInForeground(int pid, boolean inForeground) { | 85 private void setInForeground(int pid, boolean inForeground) { |
84 assert mPid == pid; | 86 assert mPid == pid; |
85 ChildProcessLauncher.getBindingManager().setInForeground(mPid, inForegro
und); | 87 ChildProcessLauncher.getBindingManager().setInForeground(mPid, inForegro
und); |
86 } | 88 } |
87 | 89 |
88 @CalledByNative | 90 @CalledByNative |
89 private static void stop(int pid) { | 91 private static void stop(int pid) { |
90 ChildProcessLauncher.stop(pid); | 92 ChildProcessLauncher.stop(pid); |
91 } | 93 } |
92 | 94 |
| 95 // Called on UI thread. |
| 96 @CalledByNative |
| 97 private static int getNumberOfRendererSlots() { |
| 98 final ChildProcessCreationParams params = ChildProcessCreationParams.get
Default(); |
| 99 final Context context = ContextUtils.getApplicationContext(); |
| 100 final boolean inSandbox = true; |
| 101 final String packageName = |
| 102 params == null ? context.getPackageName() : params.getPackageNam
e(); |
| 103 try { |
| 104 return ChildProcessLauncher.getNumberOfServices(context, inSandbox,
packageName); |
| 105 } catch (RuntimeException e) { |
| 106 // Unittest packages do not declare services. Some tests require a r
ealistic number |
| 107 // to test child process policies, so pick a high-ish number here. |
| 108 return 65535; |
| 109 } |
| 110 } |
| 111 |
93 // Can be called on a number of threads, including launcher, and binder. | 112 // Can be called on a number of threads, including launcher, and binder. |
94 private static native void nativeOnChildProcessStarted( | 113 private static native void nativeOnChildProcessStarted( |
95 long nativeChildProcessLauncherHelper, int pid); | 114 long nativeChildProcessLauncherHelper, int pid); |
96 } | 115 } |
OLD | NEW |