• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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/bind.h"
10 #include "mojo/android/javatests/mojo_test_case.h"
11 #include "mojo/android/javatests/validation_test_util.h"
12 #include "mojo/android/system/core_impl.h"
13 #include "mojo/edk/embedder/embedder.h"
14 
15 namespace {
16 
17 base::android::RegistrationMethod kMojoRegisteredMethods[] = {
18   { "CoreImpl", mojo::android::RegisterCoreImpl },
19   { "MojoTestCase", mojo::android::RegisterMojoTestCase },
20   { "ValidationTestUtil", mojo::android::RegisterValidationTestUtil },
21 };
22 
RegisterJNI(JNIEnv * env)23 bool RegisterJNI(JNIEnv* env) {
24   return base::android::RegisterJni(env) &&
25       RegisterNativeMethods(env, kMojoRegisteredMethods,
26                             arraysize(kMojoRegisteredMethods));
27 }
28 
Init()29 bool Init() {
30   mojo::edk::Init();
31   return true;
32 }
33 
34 }  // namespace
35 
JNI_OnLoad(JavaVM * vm,void * reserved)36 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
37   std::vector<base::android::RegisterCallback> register_callbacks;
38   register_callbacks.push_back(base::Bind(&RegisterJNI));
39   std::vector<base::android::InitCallback> init_callbacks;
40   init_callbacks.push_back(base::Bind(&Init));
41   if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
42       !base::android::OnJNIOnLoadInit(init_callbacks))
43     return -1;
44 
45   return JNI_VERSION_1_4;
46 }
47