| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/android/base_jni_onload.h" |
| 5 #include "base/android/base_jni_registrar.h" | 6 #include "base/android/base_jni_registrar.h" |
| 6 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 7 #include "base/android/jni_registrar.h" | 8 #include "base/android/jni_registrar.h" |
| 8 #include "base/android/library_loader/library_loader_hooks.h" | 9 #include "base/bind.h" |
| 9 #include "mojo/android/javatests/mojo_test_case.h" | 10 #include "mojo/android/javatests/mojo_test_case.h" |
| 10 #include "mojo/android/javatests/validation_test_util.h" | 11 #include "mojo/android/javatests/validation_test_util.h" |
| 11 #include "mojo/android/system/core_impl.h" | 12 #include "mojo/android/system/core_impl.h" |
| 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 13 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 13 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h" | 14 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 base::android::RegistrationMethod kMojoRegisteredMethods[] = { | 18 base::android::RegistrationMethod kMojoRegisteredMethods[] = { |
| 18 { "CoreImpl", mojo::android::RegisterCoreImpl }, | 19 { "CoreImpl", mojo::android::RegisterCoreImpl }, |
| 19 { "MojoTestCase", mojo::android::RegisterMojoTestCase }, | 20 { "MojoTestCase", mojo::android::RegisterMojoTestCase }, |
| 20 { "ValidationTestUtil", mojo::android::RegisterValidationTestUtil }, | 21 { "ValidationTestUtil", mojo::android::RegisterValidationTestUtil }, |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 bool RegisterMojoJni(JNIEnv* env) { | 24 bool RegisterJNI(JNIEnv* env) { |
| 24 return RegisterNativeMethods(env, kMojoRegisteredMethods, | 25 return base::android::RegisterJni(env) && |
| 25 arraysize(kMojoRegisteredMethods)); | 26 RegisterNativeMethods(env, kMojoRegisteredMethods, |
| 27 arraysize(kMojoRegisteredMethods)); |
| 28 } |
| 29 |
| 30 bool Init() { |
| 31 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
| 32 new mojo::embedder::SimplePlatformSupport())); |
| 33 return true; |
| 26 } | 34 } |
| 27 | 35 |
| 28 } // namespace | 36 } // namespace |
| 29 | 37 |
| 30 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 38 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 31 base::android::InitVM(vm); | 39 std::vector<base::android::RegisterCallback> register_callbacks; |
| 32 JNIEnv* env = base::android::AttachCurrentThread(); | 40 register_callbacks.push_back(base::Bind(&RegisterJNI)); |
| 33 | 41 std::vector<base::android::InitCallback> init_callbacks; |
| 34 if (!base::android::RegisterLibraryLoaderEntryHook(env)) | 42 init_callbacks.push_back(base::Bind(&Init)); |
| 43 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || |
| 44 !base::android::OnJNIOnLoadInit(init_callbacks)) |
| 35 return -1; | 45 return -1; |
| 36 | 46 |
| 37 if (!base::android::RegisterJni(env)) | |
| 38 return -1; | |
| 39 | |
| 40 if (!RegisterMojoJni(env)) | |
| 41 return -1; | |
| 42 | |
| 43 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | |
| 44 new mojo::embedder::SimplePlatformSupport())); | |
| 45 | |
| 46 return JNI_VERSION_1_4; | 47 return JNI_VERSION_1_4; |
| 47 } | 48 } |
| OLD | NEW |