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

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

Issue 864563002: Separate JNI registration with initialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and sync Created 5 years, 11 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') | chrome/chrome_android.gypi » ('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 1d6e8a1f2d57abac40775bd0c498fc3ef586aa4b..75afa88dcddde0613a659a66973145f1aa5399be 100644
--- a/chrome/app/android/chrome_jni_onload.cc
+++ b/chrome/app/android/chrome_jni_onload.cc
@@ -2,16 +2,37 @@
// 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 "base/android/jni_onload_delegate.h"
#include "chrome/app/android/chrome_android_initializer.h"
-#include "chrome/app/android/chrome_main_delegate_android.h"
+#include "content/public/app/content_jni_onload.h"
+
+namespace {
+
+class ChromeJNIOnLoadDelegate : public base::android::JNIOnLoadDelegate {
+ public:
+ bool RegisterJNI(JNIEnv* env) override;
+ bool Init() override;
+};
+
+bool ChromeJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) {
+ return true;
+}
+
+bool ChromeJNIOnLoadDelegate::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.
-// Note that this file must be included in the final shared_library build step
-// and not in a static library or the JNI_OnLoad symbol won't be included
-// because the Android build is compiled with exclude-libs=ALL to reduce symbol
-// size.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
- return RunChrome(vm, ChromeMainDelegateAndroid::Create());
+ ChromeJNIOnLoadDelegate delegate;
+ if (!content::android::OnJNIOnLoad(vm, &delegate))
+ return -1;
+
+ return JNI_VERSION_1_4;
}
« no previous file with comments | « chrome/app/android/chrome_android_initializer.cc ('k') | chrome/chrome_android.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698