Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: trunk/src/base/android/jni_generator/testMultipleJNIAdditionalImport.golden

Issue 492713002: Revert 290810 "Make class lookup lazy in jni_generator when usin..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 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/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 #if __clang__
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunused-function"
25 #endif
26 // Leaking this jclass as we cannot use LazyInstance from some threads. 22 // Leaking this jclass as we cannot use LazyInstance from some threads.
27 jclass g_Foo_clazz = NULL; 23 jclass g_Foo_clazz = NULL;
28 jclass Foo_clazz(JNIEnv*) { return g_Foo_clazz; }
29 #if __clang__
30 #pragma clang diagnostic pop
31 #endif
32 24
33 } // namespace 25 } // namespace
34 26
35 static void DoSomething(JNIEnv* env, jclass jcaller, 27 static void DoSomething(JNIEnv* env, jclass jcaller,
36 jobject callback1, 28 jobject callback1,
37 jobject callback2); 29 jobject callback2);
38 30
39 // Step 2: method stubs. 31 // Step 2: method stubs.
40 32
41 static base::subtle::AtomicWord g_Foo_calledByNative = 0; 33 static base::subtle::AtomicWord g_Foo_calledByNative = 0;
42 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback1, 34 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback1,
43 jobject callback2) { 35 jobject callback2) {
44 /* Must call RegisterNativesImpl() */ 36 /* Must call RegisterNativesImpl() */
45 CHECK_CLAZZ(env, Foo_clazz(env), 37 CHECK_CLAZZ(env, g_Foo_clazz,
46 Foo_clazz(env)); 38 g_Foo_clazz);
47 jmethodID method_id = 39 jmethodID method_id =
48 base::android::MethodID::LazyGet< 40 base::android::MethodID::LazyGet<
49 base::android::MethodID::TYPE_STATIC>( 41 base::android::MethodID::TYPE_STATIC>(
50 env, Foo_clazz(env), 42 env, g_Foo_clazz,
51 "calledByNative", 43 "calledByNative",
52 44
53 "(" 45 "("
54 "Lorg/chromium/foo/Bar1$Callback;" 46 "Lorg/chromium/foo/Bar1$Callback;"
55 "Lorg/chromium/foo/Bar2$Callback;" 47 "Lorg/chromium/foo/Bar2$Callback;"
56 ")" 48 ")"
57 "V", 49 "V",
58 &g_Foo_calledByNative); 50 &g_Foo_calledByNative);
59 51
60 env->CallStaticVoidMethod(Foo_clazz(env), 52 env->CallStaticVoidMethod(g_Foo_clazz,
61 method_id, callback1, callback2); 53 method_id, callback1, callback2);
62 jni_generator::CheckException(env); 54 jni_generator::CheckException(env);
63 55
64 } 56 }
65 57
66 // Step 3: RegisterNatives. 58 // Step 3: RegisterNatives.
67 59
68 static const JNINativeMethod kMethodsFoo[] = { 60 static const JNINativeMethod kMethodsFoo[] = {
69 { "nativeDoSomething", 61 { "nativeDoSomething",
70 "(" 62 "("
71 "Lorg/chromium/foo/Bar1$Callback;" 63 "Lorg/chromium/foo/Bar1$Callback;"
72 "Lorg/chromium/foo/Bar2$Callback;" 64 "Lorg/chromium/foo/Bar2$Callback;"
73 ")" 65 ")"
74 "V", reinterpret_cast<void*>(DoSomething) }, 66 "V", reinterpret_cast<void*>(DoSomething) },
75 }; 67 };
76 68
77 static bool RegisterNativesImpl(JNIEnv* env) { 69 static bool RegisterNativesImpl(JNIEnv* env) {
78 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 70 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
79 base::android::GetClass(env, kFooClassPath).obj())); 71 base::android::GetClass(env, kFooClassPath).obj()));
80 72
81 const int kMethodsFooSize = arraysize(kMethodsFoo); 73 const int kMethodsFooSize = arraysize(kMethodsFoo);
82 74
83 if (env->RegisterNatives(Foo_clazz(env), 75 if (env->RegisterNatives(g_Foo_clazz,
84 kMethodsFoo, 76 kMethodsFoo,
85 kMethodsFooSize) < 0) { 77 kMethodsFooSize) < 0) {
86 jni_generator::HandleRegistrationError( 78 jni_generator::HandleRegistrationError(
87 env, Foo_clazz(env), __FILE__); 79 env, g_Foo_clazz, __FILE__);
88 return false; 80 return false;
89 } 81 }
90 82
91 return true; 83 return true;
92 } 84 }
93 85
94 #endif // org_chromium_foo_Foo_JNI 86 #endif // org_chromium_foo_Foo_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698