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

Unified Diff: base/android/java/src/org/chromium/base/JNIUtils.java

Issue 2501193003: Selectively perform JNI registration in render processes on Android. (Closed)
Patch Set: Conditionally register JNI based on process type. Created 3 years, 11 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: base/android/java/src/org/chromium/base/JNIUtils.java
diff --git a/base/android/java/src/org/chromium/base/JNIUtils.java b/base/android/java/src/org/chromium/base/JNIUtils.java
index f971b5e03cebd984bcd14066947c40a475f2afe4..51c4bfa130d7187ae768ff2a07a07dbc8853ee11 100644
--- a/base/android/java/src/org/chromium/base/JNIUtils.java
+++ b/base/android/java/src/org/chromium/base/JNIUtils.java
@@ -4,6 +4,7 @@
package org.chromium.base;
+import org.chromium.base.JniRegistrationType.JniRegistrationTypeEnum;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.MainDex;
@@ -12,6 +13,9 @@ import org.chromium.base.annotations.MainDex;
*/
@MainDex
public class JNIUtils {
+ @JniRegistrationTypeEnum
+ private static int sJniRegistrationType = JniRegistrationType.ALL_JNI_REGISTRATION;
+
/**
* This returns a ClassLoader that is capable of loading Chromium Java code. Such a ClassLoader
* is needed for the few cases where the JNI mechanism is unable to automatically determine the
@@ -21,4 +25,23 @@ public class JNIUtils {
public static Object getClassLoader() {
return JNIUtils.class.getClassLoader();
}
+
+ /**
+ * @return the type of JNI registration to perform when the native libraries are loaded.
+ */
+ @JniRegistrationTypeEnum
+ @CalledByNative
+ public static int getJniRegistrationType() {
+ return sJniRegistrationType;
+ }
+
+ /**
+ * Set the JNI registration type so that native side can register the correct JNI methods.
+ * Must be called before the native library is loaded.
+ * @param jniRegistrationType the type of JNI registration to perform when loading native
+ * libraries.
+ */
+ public static void setJniRegistrationType(@JniRegistrationTypeEnum int jniRegistrationType) {
+ sJniRegistrationType = jniRegistrationType;
+ }
}
« no previous file with comments | « base/BUILD.gn ('k') | base/android/jni_android.h » ('j') | base/android/jni_android.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698