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

Unified Diff: content/app/android/library_loader_hooks.cc

Issue 50493015: Allow JNI registration to be performed eagerly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
« no previous file with comments | « chrome/app/android/chrome_android_initializer.cc ('k') | content/public/app/android_library_loader_hooks.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/app/android/library_loader_hooks.cc
diff --git a/content/app/android/library_loader_hooks.cc b/content/app/android/library_loader_hooks.cc
index 5ef9461c5988de393b24ee9f3debdc58753426cb..4b7f5133ef906f9057561d67eea3de614729b8e6 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -32,11 +32,56 @@
#include "ui/gl/android/gl_jni_registrar.h"
#include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
+namespace content {
+
namespace {
+
base::AtExitManager* g_at_exit_manager = NULL;
+
+bool DoJniRegistration(JNIEnv* env) {
+ static bool g_jni_init_done = false;
+
+ if (!g_jni_init_done) {
+ if (!base::android::RegisterJni(env))
+ return false;
+
+ if (!gfx::android::RegisterJni(env))
+ return false;
+
+ if (!net::android::RegisterJni(env))
+ return false;
+
+ if (!ui::android::RegisterJni(env))
+ return false;
+
+ if (!ui::gl::android::RegisterJni(env))
+ return false;
+
+ if (!ui::shell_dialogs::RegisterJni(env))
+ return false;
+
+ if (!content::android::RegisterChildJni(env))
+ return false;
+
+ if (!content::android::RegisterCommonJni(env))
+ return false;
+
+ if (!content::android::RegisterBrowserJni(env))
+ return false;
+
+ if (!content::android::RegisterAppJni(env))
+ return false;
+
+ if (!media::RegisterJni(env))
+ return false;
+
+ g_jni_init_done = true;
+ }
+
+ return true;
}
-namespace content {
+} // namespace
static jint LibraryLoaded(JNIEnv* env, jclass clazz,
jobjectArray init_command_line) {
@@ -72,37 +117,7 @@ static jint LibraryLoaded(JNIEnv* env, jclass clazz,
VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
<< ", default verbosity = " << logging::GetVlogVerbosity();
- if (!base::android::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!gfx::android::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!net::android::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!ui::android::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!ui::gl::android::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!ui::shell_dialogs::RegisterJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!content::android::RegisterChildJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!content::android::RegisterCommonJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!content::android::RegisterBrowserJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!content::android::RegisterAppJni(env))
- return RESULT_CODE_FAILED_TO_REGISTER_JNI;
-
- if (!media::RegisterJni(env))
+ if (!DoJniRegistration(env))
return RESULT_CODE_FAILED_TO_REGISTER_JNI;
return 0;
@@ -126,11 +141,17 @@ void LibraryLoaderExitHook() {
}
}
-bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
+bool RegisterLibraryLoaderEntryHook(JNIEnv* env, bool lazy_jni_registration) {
Yaron 2013/10/31 21:28:31 Alternatively, just make DoJniRegistration public
// We need the AtExitManager to be created at the very beginning.
g_at_exit_manager = new base::AtExitManager();
- return RegisterNativesImpl(env);
+ if (!RegisterNativesImpl(env))
+ return false;
+
+ if (!lazy_jni_registration && !DoJniRegistration(env))
+ return false;
+
+ return true;
}
} // namespace content
« no previous file with comments | « chrome/app/android/chrome_android_initializer.cc ('k') | content/public/app/android_library_loader_hooks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698