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

Unified Diff: base/android/jni_generator/jni_generator.py

Issue 2501193003: Selectively perform JNI registration in render processes on Android. (Closed)
Patch Set: Conditionally register JNI based on process type. Created 4 years 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.py
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py
index 0173a2c1172e0bf21de939fb3cd0e6fcae86e311..3241622a6cad09d1ea64f363bb6096c570fd2b48 100755
--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -632,10 +632,9 @@ class JNIFromJavaP(object):
self.constant_fields.append(
ConstantField(name=match.group('name'),
value=value.group('value')))
-
self.inl_header_file_generator = InlHeaderFileGenerator(
- self.namespace, self.fully_qualified_class, [],
- self.called_by_natives, self.constant_fields, options)
+ self.namespace, self.fully_qualified_class, [], self.called_by_natives,
+ self.constant_fields, options)
def GetContent(self):
return self.inl_header_file_generator.GetContent()
@@ -669,12 +668,13 @@ class JNIFromJavaSource(object):
jni_namespace = ExtractJNINamespace(contents) or options.namespace
natives = ExtractNatives(contents, options.ptr_type)
called_by_natives = ExtractCalledByNatives(contents)
+ maindex = '@MainDex' in contents
Torne 2016/12/14 11:40:24 The other Extract* functions are doing more than j
if len(natives) == 0 and len(called_by_natives) == 0:
raise SyntaxError('Unable to find any JNI methods for %s.' %
fully_qualified_class)
inl_header_file_generator = InlHeaderFileGenerator(
- jni_namespace, fully_qualified_class, natives, called_by_natives,
- [], options)
+ jni_namespace, fully_qualified_class, natives, called_by_natives, [],
+ options, maindex)
self.content = inl_header_file_generator.GetContent()
@classmethod
@@ -710,7 +710,7 @@ class InlHeaderFileGenerator(object):
"""Generates an inline header file for JNI integration."""
def __init__(self, namespace, fully_qualified_class, natives,
- called_by_natives, constant_fields, options):
+ called_by_natives, constant_fields, options, maindex=False):
self.namespace = namespace
self.fully_qualified_class = fully_qualified_class
self.class_name = self.fully_qualified_class.split('/')[-1]
@@ -718,6 +718,7 @@ class InlHeaderFileGenerator(object):
self.called_by_natives = called_by_natives
self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI'
self.constant_fields = constant_fields
+ self.maindex = maindex
self.options = options
@@ -864,6 +865,15 @@ ${NATIVES}
early_exit = """\
if (base::android::IsManualJniRegistrationDisabled()) return true;
"""
+ if not self.maindex:
+ early_exit += """\
+ base::android::LibraryProcessType proc_type =
Torne 2016/12/14 11:40:24 Can you put this in jni_generator_helper.h as an i
+ base::android::GetLibraryProcessType(env);
Torne 2016/12/14 11:40:24 GetLibraryProcessType is a JNI call; if we're goin
+ if (proc_type != base::android::PROCESS_BROWSER &&
+ proc_type != base::android::PROCESS_UNINITIALIZED) {
Torne 2016/12/14 11:40:25 Is there really a case where the process type is u
+ return true;
+ }
+"""
values = {'REGISTER_NATIVES_SIGNATURE': signature,
'EARLY_EXIT': early_exit,
« no previous file with comments | « base/android/jni_generator/SampleForTests_jni.golden ('k') | base/android/jni_generator/jni_generator_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698