summaryrefslogtreecommitdiffstats
path: root/xpcom
diff options
context:
space:
mode:
Diffstat (limited to 'xpcom')
-rw-r--r--xpcom/base/nsIWeakReference.idl5
-rw-r--r--xpcom/glue/nsWeakReference.cpp1
2 files changed, 6 insertions, 0 deletions
diff --git a/xpcom/base/nsIWeakReference.idl b/xpcom/base/nsIWeakReference.idl
index 73390b15f..7f6880fad 100644
--- a/xpcom/base/nsIWeakReference.idl
+++ b/xpcom/base/nsIWeakReference.idl
@@ -37,6 +37,11 @@ interface nsIWeakReference : nsISupports
%{C++
virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0;
+
+ /**
+ * Returns true if the referring object is alive. Otherwise, false.
+ */
+ virtual bool IsAlive() const = 0;
%}
};
diff --git a/xpcom/glue/nsWeakReference.cpp b/xpcom/glue/nsWeakReference.cpp
index 57f372641..be263e1c2 100644
--- a/xpcom/glue/nsWeakReference.cpp
+++ b/xpcom/glue/nsWeakReference.cpp
@@ -37,6 +37,7 @@ public:
// nsIWeakReference...
NS_DECL_NSIWEAKREFERENCE
virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
+ bool IsAlive() const override { return mReferent != nullptr; }
private:
MOZ_WEAKREF_DECL_OWNINGTHREAD