blob: bfcd98cd30b7fb1811435aa43471b5685bc687cc [file] [log] [blame]
// Copyright 2014 The Chromium Authors
// 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 <jni.h>
#include "base/android/jni_generator/jni_generator_helper.h"
// Step 1: Forward declarations.
JNI_REGISTRATION_EXPORT extern const char kClassPath_org_chromium_foo_Foo[];
const char kClassPath_org_chromium_foo_Foo[] = "org/chromium/foo/Foo";
// Leaking this jclass as we cannot use LazyInstance from some threads.
JNI_REGISTRATION_EXPORT std::atomic<jclass> g_org_chromium_foo_Foo_clazz(nullptr);
#ifndef org_chromium_foo_Foo_clazz_defined
#define org_chromium_foo_Foo_clazz_defined
inline jclass org_chromium_foo_Foo_clazz(JNIEnv* env) {
return base::android::LazyGetClass(env, kClassPath_org_chromium_foo_Foo,
&g_org_chromium_foo_Foo_clazz);
}
#endif
// Step 2: Constants (optional).
// Step 3: Method stubs.
static void JNI_Foo_DoSomething(JNIEnv* env, const base::android::JavaParamRef<jobject>& callback);
JNI_GENERATOR_EXPORT void Java_org_chromium_foo_Foo_nativeDoSomething(
JNIEnv* env,
jclass jcaller,
jobject callback) {
return JNI_Foo_DoSomething(env, base::android::JavaParamRef<jobject>(env, callback));
}
static std::atomic<jmethodID> g_org_chromium_foo_Foo_calledByNative(nullptr);
static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRef<jobject>& callback) {
jclass clazz = org_chromium_foo_Foo_clazz(env);
CHECK_CLAZZ(env, clazz,
org_chromium_foo_Foo_clazz(env));
jni_generator::JniJavaCallContextChecked call_context;
call_context.Init<
base::android::MethodID::TYPE_STATIC>(
env,
clazz,
"calledByNative",
"(Lorg/chromium/foo/Bar$Callback;)V",
&g_org_chromium_foo_Foo_calledByNative);
env->CallStaticVoidMethod(clazz,
call_context.base.method_id, callback.obj());
}
#endif // org_chromium_foo_Foo_JNI