OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file is autogenerated by | 5 // This file is autogenerated by |
6 // base/android/jni_generator/jni_generator.py | 6 // base/android/jni_generator/jni_generator.py |
7 // For | 7 // For |
8 // org/chromium/foo/Foo | 8 // org/chromium/foo/Foo |
9 | 9 |
10 #ifndef org_chromium_foo_Foo_JNI | 10 #ifndef org_chromium_foo_Foo_JNI |
11 #define org_chromium_foo_Foo_JNI | 11 #define org_chromium_foo_Foo_JNI |
12 | 12 |
13 #include <jni.h> | 13 #include <jni.h> |
14 | 14 |
15 #include "base/android/jni_generator/jni_generator_helper.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
16 | 16 |
17 #include "base/android/jni_int_wrapper.h" | 17 #include "base/android/jni_int_wrapper.h" |
18 | 18 |
19 // Step 1: forward declarations. | 19 // Step 1: forward declarations. |
20 namespace { | 20 namespace { |
21 const char kFooClassPath[] = "org/chromium/foo/Foo"; | 21 const char kFooClassPath[] = "org/chromium/foo/Foo"; |
22 // Leaking this jclass as we cannot use LazyInstance from some threads. | 22 // Leaking this jclass as we cannot use LazyInstance from some threads. |
23 base::subtle::AtomicWord g_Foo_clazz __attribute__((unused)) = 0; | 23 base::subtle::AtomicWord g_Foo_clazz __attribute__((unused)) = 0; |
24 #define Foo_clazz(env) base::android::LazyGetClass(env, kFooClassPath, &g_Foo_cl
azz) | 24 #define Foo_clazz(env) base::android::LazyGetClass(env, kFooClassPath, &g_Foo_cl
azz) |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 // Step 2: method stubs. | 28 // Step 2: method stubs. |
29 | 29 |
30 static void DoSomething(JNIEnv* env, const JavaParamRef<jclass>& jcaller, | 30 static void DoSomething(JNIEnv* env, const base::android::JavaParamRef<jclass>& |
31 const JavaParamRef<jobject>& callback1, | 31 jcaller, |
32 const JavaParamRef<jobject>& callback2); | 32 const base::android::JavaParamRef<jobject>& callback1, |
| 33 const base::android::JavaParamRef<jobject>& callback2); |
33 | 34 |
34 extern "C" __attribute__((visibility("default"))) | 35 extern "C" __attribute__((visibility("default"))) |
35 void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass jcaller, | 36 void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass jcaller, |
36 jobject callback1, | 37 jobject callback1, |
37 jobject callback2) { | 38 jobject callback2) { |
38 return DoSomething(env, JavaParamRef<jclass>(env, jcaller), | 39 return DoSomething(env, base::android::JavaParamRef<jclass>(env, jcaller), |
39 JavaParamRef<jobject>(env, callback1), JavaParamRef<jobject>(env, | 40 base::android::JavaParamRef<jobject>(env, callback1), |
40 callback2)); | 41 base::android::JavaParamRef<jobject>(env, callback2)); |
41 } | 42 } |
42 | 43 |
43 static base::subtle::AtomicWord g_Foo_calledByNative = 0; | 44 static base::subtle::AtomicWord g_Foo_calledByNative = 0; |
44 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback1, | 45 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback1, |
45 jobject callback2) { | 46 jobject callback2) { |
46 CHECK_CLAZZ(env, Foo_clazz(env), | 47 CHECK_CLAZZ(env, Foo_clazz(env), |
47 Foo_clazz(env)); | 48 Foo_clazz(env)); |
48 jmethodID method_id = | 49 jmethodID method_id = |
49 base::android::MethodID::LazyGet< | 50 base::android::MethodID::LazyGet< |
50 base::android::MethodID::TYPE_STATIC>( | 51 base::android::MethodID::TYPE_STATIC>( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 kMethodsFooSize) < 0) { | 86 kMethodsFooSize) < 0) { |
86 jni_generator::HandleRegistrationError( | 87 jni_generator::HandleRegistrationError( |
87 env, Foo_clazz(env), __FILE__); | 88 env, Foo_clazz(env), __FILE__); |
88 return false; | 89 return false; |
89 } | 90 } |
90 | 91 |
91 return true; | 92 return true; |
92 } | 93 } |
93 | 94 |
94 #endif // org_chromium_foo_Foo_JNI | 95 #endif // org_chromium_foo_Foo_JNI |
OLD | NEW |