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

Unified Diff: mojo/android/javatests/init_library.cc

Issue 984163002: Refactoring mojo android init_library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/android/javatests/init_library.cc
diff --git a/mojo/android/javatests/init_library.cc b/mojo/android/javatests/init_library.cc
index 958d8eea01d700d7bbf66d2b6f1b07996547458d..5d57ccfadd8577bd89786dea5c2b96352b8e3de9 100644
--- a/mojo/android/javatests/init_library.cc
+++ b/mojo/android/javatests/init_library.cc
@@ -2,10 +2,11 @@
// 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"
-#include "base/android/library_loader/library_loader_hooks.h"
+#include "base/bind.h"
#include "mojo/android/javatests/mojo_test_case.h"
#include "mojo/android/javatests/validation_test_util.h"
#include "mojo/android/system/core_impl.h"
@@ -20,28 +21,28 @@ base::android::RegistrationMethod kMojoRegisteredMethods[] = {
{ "ValidationTestUtil", mojo::android::RegisterValidationTestUtil },
};
-bool RegisterMojoJni(JNIEnv* env) {
- return RegisterNativeMethods(env, kMojoRegisteredMethods,
- arraysize(kMojoRegisteredMethods));
+bool RegisterJNI(JNIEnv* env) {
+ return base::android::RegisterJni(env) &&
+ RegisterNativeMethods(env, kMojoRegisteredMethods,
+ arraysize(kMojoRegisteredMethods));
+}
+
+bool Init() {
+ mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
+ new mojo::embedder::SimplePlatformSupport()));
+ return true;
}
} // namespace
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
- base::android::InitVM(vm);
- JNIEnv* env = base::android::AttachCurrentThread();
-
- if (!base::android::RegisterLibraryLoaderEntryHook(env))
- return -1;
-
- if (!base::android::RegisterJni(env))
- return -1;
-
- if (!RegisterMojoJni(env))
+ std::vector<base::android::RegisterCallback> register_callbacks;
+ register_callbacks.push_back(base::Bind(&RegisterJNI));
+ std::vector<base::android::InitCallback> init_callbacks;
+ init_callbacks.push_back(base::Bind(&Init));
+ if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
+ !base::android::OnJNIOnLoadInit(init_callbacks))
return -1;
- mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
- new mojo::embedder::SimplePlatformSupport()));
-
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