Bug 611639 - NS_ProxyRelease does not work for RefPtrs.
r=shaver a=blocking
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsProxyRelease_h__
#define nsProxyRelease_h__
#include "nsIEventTarget.h"
#include "nsCOMPtr.h"
+#include "nsAutoPtr.h"
#ifdef XPCOM_GLUE_AVOID_NSPR
#error NS_ProxyRelease implementation depends on NSPR.
#endif
/**
* Ensure that a nsCOMPtr is released on the target thread.
*
@@ -57,16 +58,31 @@ NS_ProxyRelease
(nsIEventTarget *target, nsCOMPtr<T> &doomed, PRBool alwaysProxy=PR_FALSE)
{
T* raw = nsnull;
doomed.swap(raw);
return NS_ProxyRelease(target, raw, alwaysProxy);
}
/**
+ * Ensure that a nsRefPtr is released on the target thread.
+ *
+ * @see NS_ProxyRelease(nsIEventTarget*, nsISupports*, PRBool)
+ */
+template <class T>
+inline NS_HIDDEN_(nsresult)
+NS_ProxyRelease
+ (nsIEventTarget *target, nsRefPtr<T> &doomed, PRBool alwaysProxy=PR_FALSE)
+{
+ T* raw = nsnull;
+ doomed.swap(raw);
+ return NS_ProxyRelease(target, raw, alwaysProxy);
+}
+
+/**
* Ensures that the delete of a nsISupports object occurs on the target thread.
*
* @param target
* the target thread where the doomed object should be released.
* @param doomed
* the doomed object; the object to be released on the target thread.
* @param alwaysProxy
* normally, if NS_ProxyRelease is called on the target thread, then the