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