// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file is autogenerated by // base/android/jni_generator/jni_generator.py // For // org/chromium/foo/Foo #ifndef org_chromium_foo_Foo_JNI #define org_chromium_foo_Foo_JNI #include #include "base/android/jni_generator/jni_generator_helper.h" #include "base/android/jni_int_wrapper.h" // Step 1: forward declarations. namespace { const char kFooClassPath[] = "org/chromium/foo/Foo"; // Leaking this jclass as we cannot use LazyInstance from some threads. base::subtle::AtomicWord g_Foo_clazz __attribute__((unused)) = 0; #define Foo_clazz(env) base::android::LazyGetClass(env, kFooClassPath, &g_Foo_clazz) } // namespace // Step 2: method stubs. static void DoSomething(JNIEnv* env, const base::android::JavaParamRef& jcaller, const base::android::JavaParamRef& callback); JNI_GENERATOR_EXPORT void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass jcaller, jobject callback) { return DoSomething(env, base::android::JavaParamRef(env, jcaller), base::android::JavaParamRef(env, callback)); } static base::subtle::AtomicWord g_Foo_calledByNative = 0; static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRefOrBare& callback) { CHECK_CLAZZ(env, Foo_clazz(env), Foo_clazz(env)); jmethodID method_id = base::android::MethodID::LazyGet< base::android::MethodID::TYPE_STATIC>( env, Foo_clazz(env), "calledByNative", "(" "Lorg/chromium/foo/Bar$Callback;" ")" "V", &g_Foo_calledByNative); env->CallStaticVoidMethod(Foo_clazz(env), method_id, callback.obj()); jni_generator::CheckException(env); } // Step 3: RegisterNatives. static const JNINativeMethod kMethodsFoo[] = { { "nativeDoSomething", "(" "Lorg/chromium/foo/Bar$Callback;" ")" "V", reinterpret_cast(Java_org_chromium_foo_Foo_nativeDoSomething) }, }; static bool RegisterNativesImpl(JNIEnv* env) { if (jni_generator::ShouldSkipJniRegistration(false)) return true; const int kMethodsFooSize = arraysize(kMethodsFoo); if (env->RegisterNatives(Foo_clazz(env), kMethodsFoo, kMethodsFooSize) < 0) { jni_generator::HandleRegistrationError( env, Foo_clazz(env), __FILE__); return false; } return true; } #endif // org_chromium_foo_Foo_JNI