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 jclass g_Foo_clazz = NULL; | 23 jclass g_Foo_clazz = NULL; |
24 #define Foo_clazz(env) g_Foo_clazz | 24 #define Foo_clazz(env) g_Foo_clazz |
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, jclass jcaller, | 30 static void DoSomething(JNIEnv* env, const JavaParamRef<jclass>& jcaller, |
31 jobject callback); | 31 const JavaParamRef<jobject>& callback); |
32 | 32 |
33 static void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass | 33 static void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass |
34 jcaller, | 34 jcaller, |
35 jobject callback) { | 35 jobject callback) { |
36 return DoSomething(env, jcaller, callback); | 36 return DoSomething(env, JavaParamRef<jclass>(env, jcaller), |
| 37 JavaParamRef<jobject>(env, callback)); |
37 } | 38 } |
38 | 39 |
39 static base::subtle::AtomicWord g_Foo_calledByNative = 0; | 40 static base::subtle::AtomicWord g_Foo_calledByNative = 0; |
40 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) { | 41 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) { |
41 /* Must call RegisterNativesImpl() */ | 42 /* Must call RegisterNativesImpl() */ |
42 CHECK_CLAZZ(env, Foo_clazz(env), | 43 CHECK_CLAZZ(env, Foo_clazz(env), |
43 Foo_clazz(env)); | 44 Foo_clazz(env)); |
44 jmethodID method_id = | 45 jmethodID method_id = |
45 base::android::MethodID::LazyGet< | 46 base::android::MethodID::LazyGet< |
46 base::android::MethodID::TYPE_STATIC>( | 47 base::android::MethodID::TYPE_STATIC>( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 kMethodsFooSize) < 0) { | 82 kMethodsFooSize) < 0) { |
82 jni_generator::HandleRegistrationError( | 83 jni_generator::HandleRegistrationError( |
83 env, Foo_clazz(env), __FILE__); | 84 env, Foo_clazz(env), __FILE__); |
84 return false; | 85 return false; |
85 } | 86 } |
86 | 87 |
87 return true; | 88 return true; |
88 } | 89 } |
89 | 90 |
90 #endif // org_chromium_foo_Foo_JNI | 91 #endif // org_chromium_foo_Foo_JNI |
OLD | NEW |