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

Unified Diff: base/android/jni_generator/jni_generator_helper.h

Issue 2501193003: Selectively perform JNI registration in render processes on Android. (Closed)
Patch Set: Update NativeInit 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/jni_generator/jni_generator_helper.h
diff --git a/base/android/jni_generator/jni_generator_helper.h b/base/android/jni_generator/jni_generator_helper.h
index 4c159c03a9f3975b08b487821a1839185918017b..e5b8ac036bb4cc5fb18586c117281bf8ba5be1fb 100644
--- a/base/android/jni_generator/jni_generator_helper.h
+++ b/base/android/jni_generator/jni_generator_helper.h
@@ -8,6 +8,7 @@
#include <jni.h>
#include "base/android/jni_android.h"
+#include "base/android/library_loader/library_loader_hooks.h"
#include "base/android/scoped_java_ref.h"
#include "base/logging.h"
#include "build/build_config.h"
@@ -42,6 +43,22 @@ inline void CheckException(JNIEnv* env) {
base::android::CheckException(env);
}
+inline bool ShouldSkipJniRegistration(bool is_maindex_class) {
+ base::android::JniRegistrationType jni_type =
+ base::android::GetJniRegistrationType();
+ if (jni_type == base::android::NO_JNI_REGISTRATION) {
+ // TODO(estevenson): Change this to a DCHECK.
+ return true;
+ } else if (jni_type == base::android::ALL_JNI_REGISTRATION) {
+ return false;
+ } else if (jni_type == base::android::SELECTIVE_JNI_REGISTRATION) {
+ return !is_maindex_class;
+ } else {
+ // The registration type isn't always initialized in tests by this point.
estevenson 2017/01/09 13:20:00 Not sure about this. In instrumentation tests the
Torne 2017/01/09 16:43:32 I don't think it's okay that we ever see PROCESS_U
estevenson 2017/01/12 03:46:49 Added init code everywhere necessary for tests.
+ return false;
+ }
+}
+
} // namespace jni_generator
#endif // BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698