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

Side by Side Diff: webrtc/sdk/android/src/jni/jni_helpers.h

Issue 2992103002: Relanding: Break peerconnection_jni.cc into multiple files, in "pc" directory. (Closed)
Patch Set: Add jni/androidnetworkmonitor_jni.h include for backwards comaptibility. Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 16 matching lines...) Expand all
27 // to the error stream. 27 // to the error stream.
28 #define CHECK_EXCEPTION(jni) \ 28 #define CHECK_EXCEPTION(jni) \
29 RTC_CHECK(!jni->ExceptionCheck()) \ 29 RTC_CHECK(!jni->ExceptionCheck()) \
30 << (jni->ExceptionDescribe(), jni->ExceptionClear(), "") 30 << (jni->ExceptionDescribe(), jni->ExceptionClear(), "")
31 31
32 // Helper that calls ptr->Release() and aborts the process with a useful 32 // Helper that calls ptr->Release() and aborts the process with a useful
33 // message if that didn't actually delete *ptr because of extra refcounts. 33 // message if that didn't actually delete *ptr because of extra refcounts.
34 #define CHECK_RELEASE(ptr) \ 34 #define CHECK_RELEASE(ptr) \
35 RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount." 35 RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
36 36
37 // Convenience macro defining JNI-accessible methods in the org.webrtc package.
38 // Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter.
39 //
40 // TODO(deadbeef): Rename this macro to something like
41 // "JNI_FUNCTION_DECLARATION", and use variable length arguments, such that you
42 // can write:
43 //
44 // JNI_FUNCTION_DECLARATION(void, nativeFoo, Type arg1, Type arg2) { ...
45 //
46 // Instead of:
47 //
48 // JNI_FUNCTION_DECLARATION(void, nativeFoo)(Type arg1, Type arg2) { ...
49 //
50 // The latter gets handled poorly by autoformatting tools.
51 #define JOW(rettype, name) \
52 extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name
53
37 namespace webrtc_jni { 54 namespace webrtc_jni {
38 55
39 jint InitGlobalJniVariables(JavaVM *jvm); 56 jint InitGlobalJniVariables(JavaVM *jvm);
40 57
41 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached. 58 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached.
42 JNIEnv* GetEnv(); 59 JNIEnv* GetEnv();
43 60
44 JavaVM *GetJVM(); 61 JavaVM *GetJVM();
45 62
46 // Return a |JNIEnv*| usable on this thread. Attaches to |g_jvm| if necessary. 63 // Return a |JNIEnv*| usable on this thread. Attaches to |g_jvm| if necessary.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. 107 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring.
91 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native); 108 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native);
92 109
93 // Given a (UTF-16) jstring return a new UTF-8 native string. 110 // Given a (UTF-16) jstring return a new UTF-8 native string.
94 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); 111 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string);
95 112
96 // Return the (singleton) Java Enum object corresponding to |index|; 113 // Return the (singleton) Java Enum object corresponding to |index|;
97 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, 114 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class,
98 const std::string& state_class_name, int index); 115 const std::string& state_class_name, int index);
99 116
117 // Return the (singleton) Java Enum object corresponding to |index|;
118 // |state_class_fragment| is something like "MediaSource$State".
119 jobject JavaEnumFromIndexAndClassName(JNIEnv* jni,
120 const std::string& state_class_fragment,
121 int index);
122
100 // Returns the name of a Java enum. 123 // Returns the name of a Java enum.
101 std::string GetJavaEnumName(JNIEnv* jni, 124 std::string GetJavaEnumName(JNIEnv* jni,
102 const std::string& className, 125 const std::string& className,
103 jobject j_enum); 126 jobject j_enum);
104 127
105 jobject NewGlobalRef(JNIEnv* jni, jobject o); 128 jobject NewGlobalRef(JNIEnv* jni, jobject o);
106 129
107 void DeleteGlobalRef(JNIEnv* jni, jobject o); 130 void DeleteGlobalRef(JNIEnv* jni, jobject o);
108 131
109 // Scope Java local references to the lifetime of this object. Use in all C++ 132 // Scope Java local references to the lifetime of this object. Use in all C++
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 private: 212 private:
190 JNIEnv* jni_; 213 JNIEnv* jni_;
191 jobject iterable_; 214 jobject iterable_;
192 215
193 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable); 216 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable);
194 }; 217 };
195 218
196 } // namespace webrtc_jni 219 } // namespace webrtc_jni
197 220
198 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ 221 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/classreferenceholder.h ('k') | webrtc/sdk/android/src/jni/jni_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698