OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/TestJni | 8 // org/chromium/TestJni |
9 | 9 |
10 #ifndef org_chromium_TestJni_JNI | 10 #ifndef org_chromium_TestJni_JNI |
11 #define org_chromium_TestJni_JNI | 11 #define org_chromium_TestJni_JNI |
12 | 12 |
13 #include <jni.h> | 13 #include <jni.h> |
14 | 14 |
15 #include "base/android/jni_android.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
16 #include "base/android/scoped_java_ref.h" | |
17 #include "base/basictypes.h" | |
18 #include "base/logging.h" | |
19 | |
20 using base::android::ScopedJavaLocalRef; | |
21 | 16 |
22 // Step 1: forward declarations. | 17 // Step 1: forward declarations. |
23 namespace { | 18 namespace { |
24 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 19 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
25 // Leaking this jclass as we cannot use LazyInstance from some threads. | 20 // Leaking this jclass as we cannot use LazyInstance from some threads. |
26 jclass g_TestJni_clazz = NULL; | 21 jclass g_TestJni_clazz = NULL; |
| 22 |
27 } // namespace | 23 } // namespace |
28 | 24 |
29 // Step 2: method stubs. | 25 // Step 2: method stubs. |
30 static void Destroy(JNIEnv* env, jobject obj, | 26 static void Destroy(JNIEnv* env, jobject obj, |
31 jlong nativeChromeBrowserProvider) { | 27 jlong nativeChromeBrowserProvider) { |
32 DCHECK(nativeChromeBrowserProvider) << "Destroy"; | |
33 ChromeBrowserProvider* native = | 28 ChromeBrowserProvider* native = |
34 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); | 29 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); |
| 30 DCHECK_NATIVE_PTR(native, "Destroy"); |
35 return native->Destroy(env, obj); | 31 return native->Destroy(env, obj); |
36 } | 32 } |
37 | 33 |
38 // Step 3: RegisterNatives. | 34 // Step 3: RegisterNatives. |
39 | 35 |
40 static bool RegisterNativesImpl(JNIEnv* env) { | 36 static const JNINativeMethod kMethodsTestJni[] = { |
41 | |
42 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
43 base::android::GetClass(env, kTestJniClassPath).obj())); | |
44 static const JNINativeMethod kMethodsTestJni[] = { | |
45 { "nativeDestroy", | 37 { "nativeDestroy", |
46 "(" | 38 "(" |
47 "J" | 39 "J" |
48 ")" | 40 ")" |
49 "V", reinterpret_cast<void*>(Destroy) }, | 41 "V", reinterpret_cast<void*>(Destroy) }, |
50 }; | 42 }; |
| 43 |
| 44 static bool RegisterNativesImpl(JNIEnv* env) { |
| 45 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 46 base::android::GetClass(env, kTestJniClassPath).obj())); |
| 47 |
51 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | 48 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); |
52 | 49 |
53 if (env->RegisterNatives(g_TestJni_clazz, | 50 if (env->RegisterNatives(g_TestJni_clazz, |
54 kMethodsTestJni, | 51 kMethodsTestJni, |
55 kMethodsTestJniSize) < 0) { | 52 kMethodsTestJniSize) < 0) { |
56 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 53 jni_generator::HandleRegistrationError( |
| 54 env, g_TestJni_clazz, __FILE__); |
57 return false; | 55 return false; |
58 } | 56 } |
59 | 57 |
60 return true; | 58 return true; |
61 } | 59 } |
62 | 60 |
63 #endif // org_chromium_TestJni_JNI | 61 #endif // org_chromium_TestJni_JNI |
OLD | NEW |