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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.base; 5 package org.chromium.base;
6 6
7 import org.chromium.base.JniRegistrationType.JniRegistrationTypeEnum;
7 import org.chromium.base.annotations.CalledByNative; 8 import org.chromium.base.annotations.CalledByNative;
8 import org.chromium.base.annotations.MainDex; 9 import org.chromium.base.annotations.MainDex;
9 10
10 /** 11 /**
11 * This class provides JNI-related methods to the native library. 12 * This class provides JNI-related methods to the native library.
12 */ 13 */
13 @MainDex 14 @MainDex
14 public class JNIUtils { 15 public class JNIUtils {
16 @JniRegistrationTypeEnum
17 private static int sJniRegistrationType = JniRegistrationType.ALL_JNI_REGIST RATION;
18
15 /** 19 /**
16 * This returns a ClassLoader that is capable of loading Chromium Java code. Such a ClassLoader 20 * This returns a ClassLoader that is capable of loading Chromium Java code. Such a ClassLoader
17 * is needed for the few cases where the JNI mechanism is unable to automati cally determine the 21 * is needed for the few cases where the JNI mechanism is unable to automati cally determine the
18 * appropriate ClassLoader instance. 22 * appropriate ClassLoader instance.
19 */ 23 */
20 @CalledByNative 24 @CalledByNative
21 public static Object getClassLoader() { 25 public static Object getClassLoader() {
22 return JNIUtils.class.getClassLoader(); 26 return JNIUtils.class.getClassLoader();
23 } 27 }
28
29 /**
30 * @return the type of JNI registration to perform when the native libraries are loaded.
31 */
32 @JniRegistrationTypeEnum
33 @CalledByNative
34 public static int getJniRegistrationType() {
35 return sJniRegistrationType;
36 }
37
38 /**
39 * Set the JNI registration type so that native side can register the correc t JNI methods.
40 * Must be called before the native library is loaded.
41 * @param jniRegistrationType the type of JNI registration to perform when l oading native
42 * libraries.
43 */
44 public static void setJniRegistrationType(@JniRegistrationTypeEnum int jniRe gistrationType) {
45 sJniRegistrationType = jniRegistrationType;
46 }
24 } 47 }
OLDNEW
« 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