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>& callback1,
40    const base::android::JavaParamRef<jobject>& callback2);
41
42JNI_GENERATOR_EXPORT void Java_org_chromium_foo_Foo_nativeDoSomething(
43    JNIEnv* env,
44    jclass jcaller,
45    jobject callback1,
46    jobject callback2) {
47  return JNI_Foo_DoSomething(env, base::android::JavaParamRef<jclass>(env, jcaller),
48      base::android::JavaParamRef<jobject>(env, callback1),
49      base::android::JavaParamRef<jobject>(env, callback2));
50}
51
52
53static base::subtle::AtomicWord g_org_chromium_foo_Foo_calledByNative = 0;
54static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRef<jobject>& callback1,
55    const base::android::JavaRef<jobject>& callback2) {
56  CHECK_CLAZZ(env, org_chromium_foo_Foo_clazz(env),
57      org_chromium_foo_Foo_clazz(env));
58  jmethodID method_id = base::android::MethodID::LazyGet<
59      base::android::MethodID::TYPE_STATIC>(
60          env, org_chromium_foo_Foo_clazz(env),
61          "calledByNative",
62          "(Lorg/chromium/foo/Bar1$Callback;Lorg/chromium/foo/Bar2$Callback;)V",
63          &g_org_chromium_foo_Foo_calledByNative);
64
65     env->CallStaticVoidMethod(org_chromium_foo_Foo_clazz(env),
66          method_id, callback1.obj(), callback2.obj());
67  jni_generator::CheckException(env);
68}
69
70#endif  // org_chromium_foo_Foo_JNI
71