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

Unified Diff: chrome/browser/android/monochrome_entry_point.cc

Issue 2593653002: Split JNI init so native library preloading dosn't cause native init. (Closed)
Patch Set: Add library initialization to AwCookieManager constructor Created 3 years, 12 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: chrome/browser/android/monochrome_entry_point.cc
diff --git a/chrome/browser/android/monochrome_entry_point.cc b/chrome/browser/android/monochrome_entry_point.cc
index d6658bebc7d1a5d80752b170874c81fb6ab1076d..a3c7f30457b627518a80a8f9137ec071ba72bc90 100644
--- a/chrome/browser/android/monochrome_entry_point.cc
+++ b/chrome/browser/android/monochrome_entry_point.cc
@@ -10,29 +10,34 @@
namespace {
-bool RegisterJNI(JNIEnv* env) {
+bool Init() {
return true;
}
-bool Init() {
- return true;
+bool NativeInit() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ int library_process_type = base::android::GetLibraryProcessType(env);
+ switch (library_process_type) {
+ case base::android::PROCESS_WEBVIEW:
+ case base::android::PROCESS_WEBVIEW_CHILD:
+ return android_webview::OnJNIOnLoadInit();
+ break;
+ case base::android::PROCESS_BROWSER:
+ case base::android::PROCESS_CHILD:
+ return android::OnJNIOnLoadInit(base::Bind(&Init));
+ break;
+ default:
+ NOTREACHED();
+ return false;
+ }
}
} // namespace
// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ base::android::DisableManualJniRegistration();
base::android::InitVM(vm);
- JNIEnv* env = base::android::AttachCurrentThread();
- bool ret;
- int library_process_type = base::android::GetLibraryProcessType(env);
- if (library_process_type == base::android::PROCESS_WEBVIEW ||
- library_process_type == base::android::PROCESS_WEBVIEW_CHILD) {
- base::android::DisableManualJniRegistration();
- ret = android_webview::OnJNIOnLoadInit();
- } else {
- ret = android::OnJNIOnLoadRegisterJNI(vm, base::Bind(&RegisterJNI)) &&
- android::OnJNIOnLoadInit(base::Bind(&Init));
- }
- return ret ? JNI_VERSION_1_4 : -1;
+ base::android::SetNativeInitializationHook(NativeInit);
+ return JNI_VERSION_1_4;
}
« chrome/browser/android/chrome_entry_point.cc ('K') | « chrome/browser/android/chrome_entry_point.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698