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

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

Issue 9599010: JNI Bindings on Chrome for Android: unfork. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/compiler_specific.h"
13
14 // Used to mark symbols to be exported in a shared library's symbol table.
15 #define JNI_EXPORT __attribute__ ((visibility("default")))
Mark Mentovai 2012/03/06 22:02:30 Unused?
bulach 2012/03/07 11:04:24 ops. this will be upstreamed soon, removed for now
12 16
13 namespace base { 17 namespace base {
14 namespace android { 18 namespace android {
15 19
16 // Attach the current thread to the VM (if necessary) and return the JNIEnv*. 20 // Attach the current thread to the VM (if necessary) and return the JNIEnv*.
17 JNIEnv* AttachCurrentThread(); 21 JNIEnv* AttachCurrentThread();
18 22
19 // Detach the current thread from VM if it is attached. 23 // Detach the current thread from VM if it is attached.
20 void DetachFromVM(); 24 void DetachFromVM();
21 25
(...skipping 11 matching lines...) Expand all
33 // must NOT release it. 37 // must NOT release it.
34 const jobject GetApplicationContext(); 38 const jobject GetApplicationContext();
35 39
36 // Finds the class named |class_name| and returns it. 40 // Finds the class named |class_name| and returns it.
37 // Use this method instead of invoking directly the JNI FindClass method (to 41 // Use this method instead of invoking directly the JNI FindClass method (to
38 // prevent leaking local references). 42 // prevent leaking local references).
39 // This method triggers a fatal assertion if the class could not be found. 43 // This method triggers a fatal assertion if the class could not be found.
40 // Use HasClass if you need to check whether the class exists. 44 // Use HasClass if you need to check whether the class exists.
41 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name); 45 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name);
42 46
47 // Similar to the above, but the caller is responsible to manage the jclass
48 // lifetime.
49 jclass GetUnscopedClass(JNIEnv* env, const char* class_name) WARN_UNUSED_RESULT;
50
43 // Returns true iff the class |class_name| could be found. 51 // Returns true iff the class |class_name| could be found.
44 bool HasClass(JNIEnv* env, const char* class_name); 52 bool HasClass(JNIEnv* env, const char* class_name);
45 53
46 // Returns the method ID for the method with the specified name and signature. 54 // Returns the method ID for the method with the specified name and signature.
47 // This method triggers a fatal assertion if the method could not be found. 55 // This method triggers a fatal assertion if the method could not be found.
48 // Use HasMethod if you need to check whether a method exists. 56 // Use HasMethod if you need to check whether a method exists.
49 jmethodID GetMethodID(JNIEnv* env, 57 jmethodID GetMethodID(JNIEnv* env,
50 const JavaRef<jclass>& clazz, 58 const JavaRef<jclass>& clazz,
51 const char* method_name, 59 const char* method_name,
52 const char* jni_signature); 60 const char* jni_signature);
53 61
62 // Similar to GetMethodID, but takes a raw jclass.
63 jmethodID GetMethodID(JNIEnv* env,
64 jclass clazz,
65 const char* method_name,
66 const char* jni_signature);
67
54 // Returns the method ID for the static method with the specified name and 68 // Returns the method ID for the static method with the specified name and
55 // signature. 69 // signature.
56 // This method triggers a fatal assertion if the method could not be found. 70 // This method triggers a fatal assertion if the method could not be found.
57 // Use HasMethod if you need to check whether a method exists. 71 // Use HasMethod if you need to check whether a method exists.
58 jmethodID GetStaticMethodID(JNIEnv* env, 72 jmethodID GetStaticMethodID(JNIEnv* env,
59 const JavaRef<jclass>& clazz, 73 const JavaRef<jclass>& clazz,
60 const char* method_name, 74 const char* method_name,
61 const char* jni_signature); 75 const char* jni_signature);
62 76
77 // Similar to the GetStaticMethodID, but takes a raw jclass.
78 jmethodID GetStaticMethodID(JNIEnv* env,
79 jclass clazz,
80 const char* method_name,
81 const char* jni_signature);
82
83
63 // Returns true iff |clazz| has a method with the specified name and signature. 84 // Returns true iff |clazz| has a method with the specified name and signature.
64 bool HasMethod(JNIEnv* env, 85 bool HasMethod(JNIEnv* env,
65 const JavaRef<jclass>& clazz, 86 const JavaRef<jclass>& clazz,
66 const char* method_name, 87 const char* method_name,
67 const char* jni_signature); 88 const char* jni_signature);
68 89
69 // Gets the method ID from the class name. Clears the pending Java exception 90 // Gets the method ID from the class name. Clears the pending Java exception
70 // and returns NULL if the method is not found. Caches results. Note that 91 // and returns NULL if the method is not found. Caches results. Note that
71 // GetMethodID() below avoids a class lookup, but does not cache results. 92 // GetMethodID() below avoids a class lookup, but does not cache results.
72 // Strings passed to this function are held in the cache and MUST remain valid 93 // Strings passed to this function are held in the cache and MUST remain valid
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // and returns true. 127 // and returns true.
107 bool ClearException(JNIEnv* env); 128 bool ClearException(JNIEnv* env);
108 129
109 // This function will call CHECK() macro if there's any pending exception. 130 // This function will call CHECK() macro if there's any pending exception.
110 void CheckException(JNIEnv* env); 131 void CheckException(JNIEnv* env);
111 132
112 } // namespace android 133 } // namespace android
113 } // namespace base 134 } // namespace base
114 135
115 #endif // BASE_ANDROID_JNI_ANDROID_H_ 136 #endif // BASE_ANDROID_JNI_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698