| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/library_loader/library_loader_hooks.h" |
| 10 #include "base/bind.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "mojo/android/system/core_impl.h" | 12 #include "mojo/android/system/core_impl.h" |
| 11 #include "sky/shell/java_service_provider.h" | 13 #include "sky/shell/java_service_provider.h" |
| 12 #include "sky/shell/platform_view.h" | 14 #include "sky/shell/platform_view.h" |
| 13 #include "sky/shell/sky_main.h" | 15 #include "sky/shell/sky_main.h" |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 base::android::RegistrationMethod kSkyRegisteredMethods[] = { | 19 base::android::RegistrationMethod kSkyRegisteredMethods[] = { |
| 18 {"CoreImpl", mojo::android::RegisterCoreImpl}, | 20 {"CoreImpl", mojo::android::RegisterCoreImpl}, |
| 19 {"JavaServiceProvider", sky::shell::RegisterJavaServiceProvider}, | 21 {"JavaServiceProvider", sky::shell::RegisterJavaServiceProvider}, |
| 20 {"SkyMain", sky::shell::RegisterSkyMain}, | 22 {"SkyMain", sky::shell::RegisterSkyMain}, |
| 21 {"PlatformView", sky::shell::PlatformView::Register}, | 23 {"PlatformView", sky::shell::PlatformView::Register}, |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 bool RegisterSkyJni(JNIEnv* env) { | 26 bool RegisterJNI(JNIEnv* env) { |
| 27 if (!base::android::RegisterJni(env)) |
| 28 return false; |
| 29 |
| 25 return RegisterNativeMethods(env, kSkyRegisteredMethods, | 30 return RegisterNativeMethods(env, kSkyRegisteredMethods, |
| 26 arraysize(kSkyRegisteredMethods)); | 31 arraysize(kSkyRegisteredMethods)); |
| 27 } | 32 } |
| 28 | 33 |
| 29 } // namespace | 34 } // namespace |
| 30 | 35 |
| 31 // This is called by the VM when the shared library is first loaded. | 36 // This is called by the VM when the shared library is first loaded. |
| 32 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 37 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 33 base::android::InitVM(vm); | 38 std::vector<base::android::RegisterCallback> register_callbacks; |
| 34 JNIEnv* env = base::android::AttachCurrentThread(); | 39 register_callbacks.push_back(base::Bind(&RegisterJNI)); |
| 35 | 40 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || |
| 36 if (!base::android::RegisterLibraryLoaderEntryHook(env)) | 41 !base::android::OnJNIOnLoadInit( |
| 42 std::vector<base::android::InitCallback>())) { |
| 37 return -1; | 43 return -1; |
| 38 | 44 } |
| 39 if (!base::android::RegisterJni(env)) | |
| 40 return -1; | |
| 41 | |
| 42 if (!RegisterSkyJni(env)) | |
| 43 return -1; | |
| 44 | 45 |
| 45 return JNI_VERSION_1_4; | 46 return JNI_VERSION_1_4; |
| 46 } | 47 } |
| OLD | NEW |