[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / base / android / jni_generator / testMultipleJNIAdditionalImport.golden
blob6de8c219f551e4add8f8d75b9abdb094682235a2
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.
5 // This file is autogenerated by
6 //     base/android/jni_generator/jni_generator.py
7 // For
8 //     org/chromium/foo/Foo
10 #ifndef org_chromium_foo_Foo_JNI
11 #define org_chromium_foo_Foo_JNI
13 #include <jni.h>
15 #include "base/android/jni_generator/jni_generator_helper.h"
17 #include "base/android/jni_int_wrapper.h"
19 // Step 1: forward declarations.
20 namespace {
21 const char kFooClassPath[] = "org/chromium/foo/Foo";
22 // Leaking this jclass as we cannot use LazyInstance from some threads.
23 jclass g_Foo_clazz = NULL;
24 #define Foo_clazz(env) g_Foo_clazz
26 }  // namespace
28 // Step 2: method stubs.
30 static void DoSomething(JNIEnv* env, const JavaParamRef<jclass>& jcaller,
31     const JavaParamRef<jobject>& callback1,
32     const JavaParamRef<jobject>& callback2);
34 static void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass
35     jcaller,
36     jobject callback1,
37     jobject callback2) {
38   return DoSomething(env, JavaParamRef<jclass>(env, jcaller),
39       JavaParamRef<jobject>(env, callback1), JavaParamRef<jobject>(env,
40       callback2));
43 static base::subtle::AtomicWord g_Foo_calledByNative = 0;
44 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback1,
45     jobject callback2) {
46   /* Must call RegisterNativesImpl()  */
47   CHECK_CLAZZ(env, Foo_clazz(env),
48       Foo_clazz(env));
49   jmethodID method_id =
50       base::android::MethodID::LazyGet<
51       base::android::MethodID::TYPE_STATIC>(
52       env, Foo_clazz(env),
53       "calledByNative",
55 "("
56 "Lorg/chromium/foo/Bar1$Callback;"
57 "Lorg/chromium/foo/Bar2$Callback;"
58 ")"
59 "V",
60       &g_Foo_calledByNative);
62      env->CallStaticVoidMethod(Foo_clazz(env),
63           method_id, callback1, callback2);
64   jni_generator::CheckException(env);
68 // Step 3: RegisterNatives.
70 static const JNINativeMethod kMethodsFoo[] = {
71     { "nativeDoSomething",
72 "("
73 "Lorg/chromium/foo/Bar1$Callback;"
74 "Lorg/chromium/foo/Bar2$Callback;"
75 ")"
76 "V", reinterpret_cast<void*>(Java_org_chromium_foo_Foo_nativeDoSomething) },
79 static bool RegisterNativesImpl(JNIEnv* env) {
81   g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
82       base::android::GetClass(env, kFooClassPath).obj()));
84   const int kMethodsFooSize = arraysize(kMethodsFoo);
86   if (env->RegisterNatives(Foo_clazz(env),
87                            kMethodsFoo,
88                            kMethodsFooSize) < 0) {
89     jni_generator::HandleRegistrationError(
90         env, Foo_clazz(env), __FILE__);
91     return false;
92   }
94   return true;
97 #endif  // org_chromium_foo_Foo_JNI