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

Side by Side Diff: webrtc/modules/utility/interface/helpers_android.h

Issue 1414793020: Remove interface directories kept to avoid breaking downstream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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
(Empty)
1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_
12 #define WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_
13
14 #pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
15
16 #include <jni.h>
17 #include <string>
18
19 // Abort the process if |jni| has a Java exception pending.
20 // TODO(henrika): merge with CHECK_JNI_EXCEPTION() in jni_helpers.h.
21 #define CHECK_EXCEPTION(jni) \
22 RTC_CHECK(!jni->ExceptionCheck()) \
23 << (jni->ExceptionDescribe(), jni->ExceptionClear(), "")
24
25 namespace webrtc {
26
27 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached.
28 JNIEnv* GetEnv(JavaVM* jvm);
29
30 // Return a |jlong| that will correctly convert back to |ptr|. This is needed
31 // because the alternative (of silently passing a 32-bit pointer to a vararg
32 // function expecting a 64-bit param) picks up garbage in the high 32 bits.
33 jlong PointerTojlong(void* ptr);
34
35 // JNIEnv-helper methods that wraps the API which uses the JNI interface
36 // pointer (JNIEnv*). It allows us to RTC_CHECK success and that no Java
37 // exception is thrown while calling the method.
38 jmethodID GetMethodID(
39 JNIEnv* jni, jclass c, const char* name, const char* signature);
40
41 jmethodID GetStaticMethodID(
42 JNIEnv* jni, jclass c, const char* name, const char* signature);
43
44 jclass FindClass(JNIEnv* jni, const char* name);
45
46 jobject NewGlobalRef(JNIEnv* jni, jobject o);
47
48 void DeleteGlobalRef(JNIEnv* jni, jobject o);
49
50 // Return thread ID as a string.
51 std::string GetThreadId();
52
53 // Return thread ID as string suitable for debug logging.
54 std::string GetThreadInfo();
55
56 // Attach thread to JVM if necessary and detach at scope end if originally
57 // attached.
58 class AttachThreadScoped {
59 public:
60 explicit AttachThreadScoped(JavaVM* jvm);
61 ~AttachThreadScoped();
62 JNIEnv* env();
63
64 private:
65 bool attached_;
66 JavaVM* jvm_;
67 JNIEnv* env_;
68 };
69
70 // Scoped holder for global Java refs.
71 template<class T> // T is jclass, jobject, jintArray, etc.
72 class ScopedGlobalRef {
73 public:
74 ScopedGlobalRef(JNIEnv* jni, T obj)
75 : jni_(jni), obj_(static_cast<T>(NewGlobalRef(jni, obj))) {}
76 ~ScopedGlobalRef() {
77 DeleteGlobalRef(jni_, obj_);
78 }
79 T operator*() const {
80 return obj_;
81 }
82 private:
83 JNIEnv* jni_;
84 T obj_;
85 };
86
87 } // namespace webrtc
88
89 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_
OLDNEW
« no previous file with comments | « webrtc/modules/utility/interface/file_recorder.h ('k') | webrtc/modules/utility/interface/helpers_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698