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

Unified Diff: chrome/app/android/chrome_jni_onload.cc

Issue 970243003: Refactoring chrome JNI registration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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_jni_onload.h ('k') | chrome/app/android/chrome_main_delegate_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/android/chrome_jni_onload.cc
diff --git a/chrome/app/android/chrome_jni_onload.cc b/chrome/app/android/chrome_jni_onload.cc
index a2052da67673cae567b48547170c97d0e460c3fd..124e3c2b7f05c18d9462228fddad4d7ba680b511 100644
--- a/chrome/app/android/chrome_jni_onload.cc
+++ b/chrome/app/android/chrome_jni_onload.cc
@@ -2,35 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/android/jni_android.h"
+#include "chrome/app/android/chrome_jni_onload.h"
+
+#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "chrome/app/android/chrome_android_initializer.h"
+#include "chrome/browser/android/chrome_jni_registrar.h"
#include "content/public/app/content_jni_onload.h"
+namespace chrome {
+namespace android {
+
namespace {
bool RegisterJNI(JNIEnv* env) {
+ if (base::android::GetLibraryProcessType(env) ==
+ base::android::PROCESS_BROWSER) {
+ return RegisterBrowserJNI(env);
+ }
return true;
}
bool Init() {
- // TODO(michaelbai): Move the JNI registration from RunChrome() to
- // RegisterJNI().
return RunChrome();
}
} // namespace
-
-// This is called by the VM when the shared library is first loaded.
-JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+bool OnJNIOnLoadRegisterJNI(
+ JavaVM* vm,
+ base::android::RegisterCallback callback) {
std::vector<base::android::RegisterCallback> register_callbacks;
+ register_callbacks.push_back(callback);
register_callbacks.push_back(base::Bind(&RegisterJNI));
+ return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks);
+}
+
+bool OnJNIOnLoadInit(base::android::InitCallback callback) {
std::vector<base::android::InitCallback> init_callbacks;
+ init_callbacks.push_back(callback);
init_callbacks.push_back(base::Bind(&Init));
- if (!content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
- !content::android::OnJNIOnLoadInit(init_callbacks)) {
- return -1;
- }
- return JNI_VERSION_1_4;
+ return content::android::OnJNIOnLoadInit(init_callbacks);
}
+
+} // namespace android
+} // namespace chrome
« no previous file with comments | « chrome/app/android/chrome_jni_onload.h ('k') | chrome/app/android/chrome_main_delegate_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698