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

Side by Side Diff: trunk/src/base/android/jni_android.h

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 (c) 2012 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 #ifndef BASE_ANDROID_JNI_ANDROID_H_ 5 #ifndef BASE_ANDROID_JNI_ANDROID_H_
6 #define BASE_ANDROID_JNI_ANDROID_H_ 6 #define BASE_ANDROID_JNI_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Returns true if the global JVM has been initialized. 47 // Returns true if the global JVM has been initialized.
48 BASE_EXPORT bool IsVMInitialized(); 48 BASE_EXPORT bool IsVMInitialized();
49 49
50 // Initializes the global application context object. The |context| can be any 50 // Initializes the global application context object. The |context| can be any
51 // valid reference to the application context. Internally holds a global ref to 51 // valid reference to the application context. Internally holds a global ref to
52 // the context. InitVM and InitApplicationContext maybe called in either order. 52 // the context. InitVM and InitApplicationContext maybe called in either order.
53 BASE_EXPORT void InitApplicationContext(JNIEnv* env, 53 BASE_EXPORT void InitApplicationContext(JNIEnv* env,
54 const JavaRef<jobject>& context); 54 const JavaRef<jobject>& context);
55 55
56 // Initializes the global ClassLoader used by the GetClass and LazyGetClass
57 // methods. This is needed because JNI will use the base ClassLoader when there
58 // is no Java code on the stack. The base ClassLoader doesn't know about any of
59 // the application classes and will fail to lookup anything other than system
60 // classes.
61 BASE_EXPORT void InitReplacementClassLoader(
62 JNIEnv* env,
63 const JavaRef<jobject>& class_loader);
64
65 // Gets a global ref to the application context set with 56 // Gets a global ref to the application context set with
66 // InitApplicationContext(). Ownership is retained by the function - the caller 57 // InitApplicationContext(). Ownership is retained by the function - the caller
67 // must NOT release it. 58 // must NOT release it.
68 const BASE_EXPORT jobject GetApplicationContext(); 59 const BASE_EXPORT jobject GetApplicationContext();
69 60
70 // Finds the class named |class_name| and returns it. 61 // Finds the class named |class_name| and returns it.
71 // Use this method instead of invoking directly the JNI FindClass method (to 62 // Use this method instead of invoking directly the JNI FindClass method (to
72 // prevent leaking local references). 63 // prevent leaking local references).
73 // This method triggers a fatal assertion if the class could not be found. 64 // This method triggers a fatal assertion if the class could not be found.
74 // Use HasClass if you need to check whether the class exists. 65 // Use HasClass if you need to check whether the class exists.
75 BASE_EXPORT ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, 66 BASE_EXPORT ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env,
76 const char* class_name); 67 const char* class_name);
77 68
78 // The method will initialize |atomic_class_id| to contain a global ref to the
79 // class. And will return that ref on subsequent calls. It's the caller's
80 // responsibility to release the ref when it is no longer needed.
81 // The caller is responsible to zero-initialize |atomic_method_id|.
82 // It's fine to simultaneously call this on multiple threads referencing the
83 // same |atomic_method_id|.
84 BASE_EXPORT jclass LazyGetClass(
85 JNIEnv* env,
86 const char* class_name,
87 base::subtle::AtomicWord* atomic_class_id);
88
89 // This class is a wrapper for JNIEnv Get(Static)MethodID. 69 // This class is a wrapper for JNIEnv Get(Static)MethodID.
90 class BASE_EXPORT MethodID { 70 class BASE_EXPORT MethodID {
91 public: 71 public:
92 enum Type { 72 enum Type {
93 TYPE_STATIC, 73 TYPE_STATIC,
94 TYPE_INSTANCE, 74 TYPE_INSTANCE,
95 }; 75 };
96 76
97 // Returns the method ID for the method with the specified name and signature. 77 // Returns the method ID for the method with the specified name and signature.
98 // This method triggers a fatal assertion if the method could not be found. 78 // This method triggers a fatal assertion if the method could not be found.
(...skipping 21 matching lines...) Expand all
120 // and returns true. 100 // and returns true.
121 BASE_EXPORT bool ClearException(JNIEnv* env); 101 BASE_EXPORT bool ClearException(JNIEnv* env);
122 102
123 // This function will call CHECK() macro if there's any pending exception. 103 // This function will call CHECK() macro if there's any pending exception.
124 BASE_EXPORT void CheckException(JNIEnv* env); 104 BASE_EXPORT void CheckException(JNIEnv* env);
125 105
126 } // namespace android 106 } // namespace android
127 } // namespace base 107 } // namespace base
128 108
129 #endif // BASE_ANDROID_JNI_ANDROID_H_ 109 #endif // BASE_ANDROID_JNI_ANDROID_H_
OLDNEW
« no previous file with comments | « trunk/src/base/android/java/src/org/chromium/base/JNIUtils.java ('k') | trunk/src/base/android/jni_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698