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

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: Simpler approach Created 7 years, 1 month 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 | « android_webview/lib/main/webview_entry_point.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..a42474879c6893ec3486ff22f504fc4ae3eef176 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -32,11 +32,54 @@
#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;
}
-namespace content {
+bool EnsureJniRegistered(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;
+}
static jint LibraryLoaded(JNIEnv* env, jclass clazz,
jobjectArray init_command_line) {
@@ -72,37 +115,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 (!EnsureJniRegistered(env))
return RESULT_CODE_FAILED_TO_REGISTER_JNI;
return 0;
« no previous file with comments | « android_webview/lib/main/webview_entry_point.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