mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-12-01 09:46:09 +03:00
67 lines
2.2 KiB
Plaintext
67 lines
2.2 KiB
Plaintext
// 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 <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<jclass>& jcaller,
|
|
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<jclass>(env, jcaller),
|
|
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) {
|
|
CHECK_CLAZZ(env, org_chromium_foo_Foo_clazz(env),
|
|
org_chromium_foo_Foo_clazz(env));
|
|
jmethodID method_id = base::android::MethodID::LazyGet<
|
|
base::android::MethodID::TYPE_STATIC>(
|
|
env, org_chromium_foo_Foo_clazz(env),
|
|
"calledByNative",
|
|
"(Lorg/chromium/foo/Bar$Callback;)V",
|
|
&g_org_chromium_foo_Foo_calledByNative);
|
|
|
|
env->CallStaticVoidMethod(org_chromium_foo_Foo_clazz(env),
|
|
method_id, callback.obj());
|
|
jni_generator::CheckException(env);
|
|
}
|
|
|
|
#endif // org_chromium_foo_Foo_JNI
|