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

Unified Diff: remoting/client/jni/chromoting_jni_onload.cc

Issue 981323002: Refactoring chromoting_jni_onload.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove the at_exit_manager and add back base::android::Register Created 5 years, 9 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 | remoting/client/jni/chromoting_jni_runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/jni/chromoting_jni_onload.cc
diff --git a/remoting/client/jni/chromoting_jni_onload.cc b/remoting/client/jni/chromoting_jni_onload.cc
index fa5539e7cbb759ebf61514d691c7078d7e4615d1..53e742087f166866534c16a33f1cbaa2459f464e 100644
--- a/remoting/client/jni/chromoting_jni_onload.cc
+++ b/remoting/client/jni/chromoting_jni_onload.cc
@@ -2,6 +2,7 @@
// 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_onload.h"
#include "base/android/base_jni_registrar.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
@@ -10,27 +11,29 @@
#include "remoting/client/jni/chromoting_jni_runtime.h"
#include "ui/gfx/android/gfx_jni_registrar.h"
-extern "C" {
+namespace {
-JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
- base::android::InitVM(vm);
+base::android::RegistrationMethod kRemotingRegisteredMethods[] = {
+ {"base", base::android::RegisterJni},
+ {"gfx", gfx::android::RegisterJni},
+ {"net", net::android::RegisterJni},
+ {"remoting", remoting::RegisterJni},
+};
- JNIEnv* env = base::android::AttachCurrentThread();
- static base::android::RegistrationMethod kRemotingRegisteredMethods[] = {
- {"base", base::android::RegisterJni},
- {"gfx", gfx::android::RegisterJni},
- {"net", net::android::RegisterJni},
- {"remoting", remoting::RegisterJni},
- };
- if (!base::android::RegisterNativeMethods(
- env, kRemotingRegisteredMethods, arraysize(kRemotingRegisteredMethods))) {
- return -1;
- }
+bool RegisterJNI(JNIEnv* env) {
+ return base::android::RegisterNativeMethods(env,
+ kRemotingRegisteredMethods, arraysize(kRemotingRegisteredMethods));
+}
- base::android::InitReplacementClassLoader(env,
- base::android::GetClassLoader(env));
+} // namespace
+JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ std::vector<base::android::RegisterCallback> register_callbacks;
+ register_callbacks.push_back(base::Bind(&RegisterJNI));
+ std::vector<base::android::InitCallback> init_callbacks;
+ if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
+ !base::android::OnJNIOnLoadInit(init_callbacks)) {
+ return -1;
+ }
return JNI_VERSION_1_4;
}
-
-} // extern "C"
« no previous file with comments | « no previous file | remoting/client/jni/chromoting_jni_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698