Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsJavaXPTCStubWeakRef Class Reference

This class represents an XPCOM weak reference to a Java object. More...

#include <nsJavaXPTCStubWeakRef.h>

Inheritance diagram for nsJavaXPTCStubWeakRef:
Inheritance graph
[legend]
Collaboration diagram for nsJavaXPTCStubWeakRef:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsJavaXPTCStubWeakRef (jobject aJavaObject, nsJavaXPTCStub *aXPTCStub)
 How we handle XPCOM weak references to a Java object:
virtual ~nsJavaXPTCStubWeakRef ()
void QueryReferent (in nsIIDRef uuid,[iid_is(uuid), retval] out nsQIResult result)
 |QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces an owning reference to the desired interface.

Protected Attributes

jobject mWeakRef
nsJavaXPTCStubmXPTCStub

Detailed Description

This class represents an XPCOM weak reference to a Java object.

Definition at line 50 of file nsJavaXPTCStubWeakRef.h.


Constructor & Destructor Documentation

How we handle XPCOM weak references to a Java object:

If XPCOM requires or asks for a weak reference of a Java object, we first find (or create) an nsJavaXPTCStub for that Java object. That way, there is always an nsJavaXPTCStub for any nsJavaXPTCStubWeakRef. However, the XPTCStub may not always be 'valid'; that is, its refcount may be zero if is not currently referenced by any XPCOM class. When an XPCOM method queries the referent from the weak reference, the weak ref checks first whether the Java object is still valid. If so, we can immediately return an addref'd nsJavaXPTCStub. The XPTCStub takes care of finding an XPTCStub for the required IID.

Definition at line 59 of file nsJavaXPTCStubWeakRef.cpp.

  : mXPTCStub(aXPTCStub)
{
  JNIEnv* env = GetJNIEnv();
  jobject weakref = env->NewObject(weakReferenceClass,
                                   weakReferenceConstructorMID, aJavaObject);
  mWeakRef = env->NewGlobalRef(weakref);
}

Here is the call graph for this function:

Definition at line 69 of file nsJavaXPTCStubWeakRef.cpp.

Here is the call graph for this function:


Member Function Documentation

void nsIWeakReference::QueryReferent ( in nsIIDRef  uuid,
[iid_is(uuid), retval] out nsQIResult  result 
) [inherited]

|QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces an owning reference to the desired interface.

It is designed to look and act exactly like (a proxied) |QueryInterface|. Don't hold on to the produced interface permanently; that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 59 of file nsJavaXPTCStubWeakRef.h.

Definition at line 60 of file nsJavaXPTCStubWeakRef.h.


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