| 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 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; | 20 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; |
| 26 // Leaking this jclass as we cannot use LazyInstance from some threads. | 21 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 27 jclass g_TestJni_clazz = NULL; | 22 jclass g_TestJni_clazz = NULL; |
| 23 |
| 28 } // namespace | 24 } // namespace |
| 29 | 25 |
| 30 static jint Init(JNIEnv* env, jobject obj); | 26 static jint Init(JNIEnv* env, jobject obj); |
| 31 | 27 |
| 32 // Step 2: method stubs. | 28 // Step 2: method stubs. |
| 33 | 29 |
| 34 // Step 3: RegisterNatives. | 30 // Step 3: RegisterNatives. |
| 35 | 31 |
| 36 static bool RegisterNativesImpl(JNIEnv* env) { | 32 static const JNINativeMethod kMethodsMyInnerClass[] = { |
| 37 | |
| 38 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 39 base::android::GetClass(env, kTestJniClassPath).obj())); | |
| 40 static const JNINativeMethod kMethodsMyInnerClass[] = { | |
| 41 { "nativeInit", | 33 { "nativeInit", |
| 42 "(" | 34 "(" |
| 43 ")" | 35 ")" |
| 44 "I", reinterpret_cast<void*>(Init) }, | 36 "I", reinterpret_cast<void*>(Init) }, |
| 45 }; | 37 }; |
| 38 |
| 39 static bool RegisterNativesImpl(JNIEnv* env) { |
| 40 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 41 base::android::GetClass(env, kTestJniClassPath).obj())); |
| 42 |
| 46 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); | 43 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); |
| 47 | 44 |
| 48 if (env->RegisterNatives(g_MyInnerClass_clazz, | 45 if (env->RegisterNatives(g_MyInnerClass_clazz, |
| 49 kMethodsMyInnerClass, | 46 kMethodsMyInnerClass, |
| 50 kMethodsMyInnerClassSize) < 0) { | 47 kMethodsMyInnerClassSize) < 0) { |
| 51 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 48 jni_generator::HandleRegistrationError( |
| 49 env, g_MyInnerClass_clazz, __FILE__); |
| 52 return false; | 50 return false; |
| 53 } | 51 } |
| 54 | 52 |
| 55 return true; | 53 return true; |
| 56 } | 54 } |
| 57 | 55 |
| 58 #endif // org_chromium_TestJni_JNI | 56 #endif // org_chromium_TestJni_JNI |
| OLD | NEW |