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

Unified Diff: mojo/services/network/android_hooks.cc

Issue 977843003: Hook-up OnJNIOnLoadRegisterJNI for JNI registration in mojo network service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Ben's comment. 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/network/android_hooks.cc
diff --git a/mojo/services/network/android_hooks.cc b/mojo/services/network/android_hooks.cc
index 190eef178580a843dbef16090d39109bdb7c5dcb..e8224023bca84f0710c4e5c2889df288ab0d8857 100644
--- a/mojo/services/network/android_hooks.cc
+++ b/mojo/services/network/android_hooks.cc
@@ -2,19 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/android/base_jni_registrar.h"
+#include <vector>
+
+#include "base/android/base_jni_onload.h"
#include "base/android/jni_android.h"
+#include "base/android/library_loader/library_loader_hooks.h"
+#include "base/bind.h"
#include "net/android/net_jni_registrar.h"
+namespace {
+bool RegisterJNI(JNIEnv* env) {
+ return net::android::RegisterJni(env);
+}
+
+bool Init() {
+ return true;
+}
+} // 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::InitVM(vm);
- JNIEnv* env = base::android::AttachCurrentThread();
+ std::vector<base::android::RegisterCallback> register_callbacks;
+ register_callbacks.push_back(base::Bind(&RegisterJNI));
- if (!base::android::RegisterJni(env))
- return -1;
+ std::vector<base::android::InitCallback> init_callbacks;
+ init_callbacks.push_back(base::Bind(&Init));
- if (!net::android::RegisterJni(env))
+ if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
+ !base::android::OnJNIOnLoadInit(init_callbacks)) {
return -1;
+ }
+
+ // There cannot be two AtExitManagers at the same time. Remove the one from
+ // LibraryLoader as ApplicationRunnerChromium also uses one.
+ base::android::LibraryLoaderExitHook();
michaelbai 2015/03/04 17:25:52 Why can't you use the AtExitManager created in bas
qsr 2015/03/04 17:28:59 We use the one in base, but we create it later on
return JNI_VERSION_1_4;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698