2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-11 20:22:48 -07:00
|
|
|
#ifndef nsProxyRelease_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
#define nsProxyRelease_h__
|
|
|
|
|
|
|
|
#include "nsIEventTarget.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2010-11-15 16:08:57 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef XPCOM_GLUE_AVOID_NSPR
|
|
|
|
#error NS_ProxyRelease implementation depends on NSPR.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that a nsCOMPtr is released on the target thread.
|
|
|
|
*
|
2011-09-28 23:19:26 -07:00
|
|
|
* @see NS_ProxyRelease(nsIEventTarget*, nsISupports*, bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
inline NS_HIDDEN_(nsresult)
|
|
|
|
NS_ProxyRelease
|
2011-09-28 23:19:26 -07:00
|
|
|
(nsIEventTarget *target, nsCOMPtr<T> &doomed, bool alwaysProxy=false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
T* raw = nsnull;
|
|
|
|
doomed.swap(raw);
|
2008-02-21 15:45:22 -08:00
|
|
|
return NS_ProxyRelease(target, raw, alwaysProxy);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-11-15 16:08:57 -08:00
|
|
|
/**
|
|
|
|
* Ensure that a nsRefPtr is released on the target thread.
|
|
|
|
*
|
2011-09-28 23:19:26 -07:00
|
|
|
* @see NS_ProxyRelease(nsIEventTarget*, nsISupports*, bool)
|
2010-11-15 16:08:57 -08:00
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
inline NS_HIDDEN_(nsresult)
|
|
|
|
NS_ProxyRelease
|
2011-09-28 23:19:26 -07:00
|
|
|
(nsIEventTarget *target, nsRefPtr<T> &doomed, bool alwaysProxy=false)
|
2010-11-15 16:08:57 -08:00
|
|
|
{
|
|
|
|
T* raw = nsnull;
|
|
|
|
doomed.swap(raw);
|
|
|
|
return NS_ProxyRelease(target, raw, alwaysProxy);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* doomed object will released directly. however, if this parameter is
|
|
|
|
* true, then an event will always be posted to the target thread for
|
|
|
|
* asynchronous release.
|
|
|
|
*/
|
|
|
|
NS_COM_GLUE nsresult
|
|
|
|
NS_ProxyRelease
|
2011-09-28 23:19:26 -07:00
|
|
|
(nsIEventTarget *target, nsISupports *doomed, bool alwaysProxy=false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif
|