| 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 kMyOtherInnerClassClassPath[] = | 19 const char kMyOtherInnerClassClassPath[] = |
| 25 "org/chromium/TestJni$MyOtherInnerClass"; | 20 "org/chromium/TestJni$MyOtherInnerClass"; |
| 26 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 21 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
| 27 // Leaking this jclass as we cannot use LazyInstance from some threads. | 22 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 28 jclass g_TestJni_clazz = NULL; | 23 jclass g_TestJni_clazz = NULL; |
| 24 |
| 29 } // namespace | 25 } // namespace |
| 30 | 26 |
| 31 static jint Init(JNIEnv* env, jobject obj); | 27 static jint Init(JNIEnv* env, jobject obj); |
| 32 | 28 |
| 33 static jint Init(JNIEnv* env, jobject obj); | 29 static jint Init(JNIEnv* env, jobject obj); |
| 34 | 30 |
| 35 // Step 2: method stubs. | 31 // Step 2: method stubs. |
| 36 | 32 |
| 37 // Step 3: RegisterNatives. | 33 // Step 3: RegisterNatives. |
| 38 | 34 |
| 39 static bool RegisterNativesImpl(JNIEnv* env) { | 35 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
| 40 | |
| 41 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 42 base::android::GetClass(env, kTestJniClassPath).obj())); | |
| 43 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | |
| 44 { "nativeInit", | 36 { "nativeInit", |
| 45 "(" | 37 "(" |
| 46 ")" | 38 ")" |
| 47 "I", reinterpret_cast<void*>(Init) }, | 39 "I", reinterpret_cast<void*>(Init) }, |
| 48 }; | 40 }; |
| 41 |
| 42 static const JNINativeMethod kMethodsTestJni[] = { |
| 43 { "nativeInit", |
| 44 "(" |
| 45 ")" |
| 46 "I", reinterpret_cast<void*>(Init) }, |
| 47 }; |
| 48 |
| 49 static bool RegisterNativesImpl(JNIEnv* env) { |
| 50 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 51 base::android::GetClass(env, kTestJniClassPath).obj())); |
| 52 |
| 49 const int kMethodsMyOtherInnerClassSize = | 53 const int kMethodsMyOtherInnerClassSize = |
| 50 arraysize(kMethodsMyOtherInnerClass); | 54 arraysize(kMethodsMyOtherInnerClass); |
| 51 | 55 |
| 52 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, | 56 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
| 53 kMethodsMyOtherInnerClass, | 57 kMethodsMyOtherInnerClass, |
| 54 kMethodsMyOtherInnerClassSize) < 0) { | 58 kMethodsMyOtherInnerClassSize) < 0) { |
| 55 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 59 jni_generator::HandleRegistrationError( |
| 60 env, g_MyOtherInnerClass_clazz, __FILE__); |
| 56 return false; | 61 return false; |
| 57 } | 62 } |
| 58 | 63 |
| 59 static const JNINativeMethod kMethodsTestJni[] = { | |
| 60 { "nativeInit", | |
| 61 "(" | |
| 62 ")" | |
| 63 "I", reinterpret_cast<void*>(Init) }, | |
| 64 }; | |
| 65 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | 64 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); |
| 66 | 65 |
| 67 if (env->RegisterNatives(g_TestJni_clazz, | 66 if (env->RegisterNatives(g_TestJni_clazz, |
| 68 kMethodsTestJni, | 67 kMethodsTestJni, |
| 69 kMethodsTestJniSize) < 0) { | 68 kMethodsTestJniSize) < 0) { |
| 70 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 69 jni_generator::HandleRegistrationError( |
| 70 env, g_TestJni_clazz, __FILE__); |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 | 73 |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 #endif // org_chromium_TestJni_JNI | 77 #endif // org_chromium_TestJni_JNI |
| OLD | NEW |