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
6// This file is autogenerated by
7//     base/android/jni_generator/jni_generator.py
8// For
9//     org/chromium/foo/Foo
10
11#ifndef org_chromium_foo_Foo_JNI
12#define org_chromium_foo_Foo_JNI
13
14#include <jni.h>
15
16#include "base/android/jni_generator/jni_generator_helper.h"
17
18
19// Step 1: Forward declarations.
20
21JNI_REGISTRATION_EXPORT extern const char kClassPath_org_chromium_foo_Foo[];
22const char kClassPath_org_chromium_foo_Foo[] = "org/chromium/foo/Foo";
23// Leaking this jclass as we cannot use LazyInstance from some threads.
24JNI_REGISTRATION_EXPORT base::subtle::AtomicWord g_org_chromium_foo_Foo_clazz = 0;
25#ifndef org_chromium_foo_Foo_clazz_defined
26#define org_chromium_foo_Foo_clazz_defined
27inline jclass org_chromium_foo_Foo_clazz(JNIEnv* env) {
28  return base::android::LazyGetClass(env, kClassPath_org_chromium_foo_Foo,
29      &g_org_chromium_foo_Foo_clazz);
30}
31#endif
32
33
34// Step 2: Constants (optional).
35
36
37// Step 3: Method stubs.
38static void JNI_Foo_DoSomething(JNIEnv* env, const base::android::JavaParamRef<jclass>& jcaller,
39    const base::android::JavaParamRef<jobject>& callback);
40
41JNI_GENERATOR_EXPORT void Java_org_chromium_foo_Foo_nativeDoSomething(
42    JNIEnv* env,
43    jclass jcaller,
44    jobject callback) {
45  return JNI_Foo_DoSomething(env, base::android::JavaParamRef<jclass>(env, jcaller),
46      base::android::JavaParamRef<jobject>(env, callback));
47}
48
49
50static base::subtle::AtomicWord g_org_chromium_foo_Foo_calledByNative = 0;
51static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRef<jobject>& callback) {
52  CHECK_CLAZZ(env, org_chromium_foo_Foo_clazz(env),
53      org_chromium_foo_Foo_clazz(env));
54  jmethodID method_id = base::android::MethodID::LazyGet<
55      base::android::MethodID::TYPE_STATIC>(
56          env, org_chromium_foo_Foo_clazz(env),
57          "calledByNative",
58          "(Lorg/chromium/foo/Bar$Callback;)V",
59          &g_org_chromium_foo_Foo_calledByNative);
60
61     env->CallStaticVoidMethod(org_chromium_foo_Foo_clazz(env),
62          method_id, callback.obj());
63  jni_generator::CheckException(env);
64}
65
66#endif  // org_chromium_foo_Foo_JNI
67