Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
fml::jni::JavaRef< jobject > Class Reference

#include <scoped_java_ref.h>

Inheritance diagram for fml::jni::JavaRef< jobject >:
fml::jni::ScopedJavaGlobalRef< jobject >

Public Member Functions

jobject obj () const
 
bool is_null () const
 

Protected Member Functions

 JavaRef ()
 
 JavaRef (JNIEnv *env, jobject obj)
 
 ~JavaRef ()
 
JNIEnv * SetNewLocalRef (JNIEnv *env, jobject obj)
 
void SetNewGlobalRef (JNIEnv *env, jobject obj)
 
void ResetLocalRef (JNIEnv *env)
 
void ResetGlobalRef ()
 
jobject ReleaseInternal ()
 

Detailed Description

Definition at line 42 of file scoped_java_ref.h.

Constructor & Destructor Documentation

◆ JavaRef() [1/2]

fml::jni::JavaRef< jobject >::JavaRef ( )
protected

Definition at line 31 of file scoped_java_ref.cc.

31: obj_(NULL) {}

◆ JavaRef() [2/2]

fml::jni::JavaRef< jobject >::JavaRef ( JNIEnv *  env,
jobject  obj 
)
protected

Definition at line 33 of file scoped_java_ref.cc.

33 : obj_(obj) {
34 if (obj) {
35 FML_DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType);
36 }
37}
#define FML_DCHECK(condition)
Definition: logging.h:103
Definition: __init__.py:1

◆ ~JavaRef()

fml::jni::JavaRef< jobject >::~JavaRef ( )
protecteddefault

Member Function Documentation

◆ is_null()

bool fml::jni::JavaRef< jobject >::is_null ( ) const
inline

Definition at line 46 of file scoped_java_ref.h.

46{ return obj_ == NULL; }

◆ obj()

jobject fml::jni::JavaRef< jobject >::obj ( ) const
inline

Definition at line 44 of file scoped_java_ref.h.

44{ return obj_; }

◆ ReleaseInternal()

jobject fml::jni::JavaRef< jobject >::ReleaseInternal ( )
protected

Definition at line 87 of file scoped_java_ref.cc.

87 {
88 jobject obj = obj_;
89 obj_ = NULL;
90 return obj;
91}

◆ ResetGlobalRef()

void fml::jni::JavaRef< jobject >::ResetGlobalRef ( )
protected

Definition at line 80 of file scoped_java_ref.cc.

80 {
81 if (obj_) {
82 AttachCurrentThread()->DeleteGlobalRef(obj_);
83 obj_ = NULL;
84 }
85}
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:34

◆ ResetLocalRef()

void fml::jni::JavaRef< jobject >::ResetLocalRef ( JNIEnv *  env)
protected

Definition at line 72 of file scoped_java_ref.cc.

72 {
73 if (obj_) {
74 FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
75 env->DeleteLocalRef(obj_);
76 obj_ = NULL;
77 }
78}

◆ SetNewGlobalRef()

void fml::jni::JavaRef< jobject >::SetNewGlobalRef ( JNIEnv *  env,
jobject  obj 
)
protected

Definition at line 57 of file scoped_java_ref.cc.

57 {
58 if (!env) {
60 } else {
61 FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
62 }
63 if (obj) {
64 obj = env->NewGlobalRef(obj);
65 }
66 if (obj_) {
67 env->DeleteGlobalRef(obj_);
68 }
69 obj_ = obj;
70}

◆ SetNewLocalRef()

JNIEnv * fml::jni::JavaRef< jobject >::SetNewLocalRef ( JNIEnv *  env,
jobject  obj 
)
protected

Definition at line 41 of file scoped_java_ref.cc.

41 {
42 if (!env) {
44 } else {
45 FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
46 }
47 if (obj) {
48 obj = env->NewLocalRef(obj);
49 }
50 if (obj_) {
51 env->DeleteLocalRef(obj_);
52 }
53 obj_ = obj;
54 return env;
55}

The documentation for this class was generated from the following files: