Bug 551298, patch D: Use NS_INLINE_DECL_REFCOUNTING in /content/ directory. r=sicking

This commit is contained in:
Daniel Holbert 2010-04-01 08:08:51 -07:00
parent 83bf8f3bd3
commit e6c10e8d77
11 changed files with 22 additions and 220 deletions

View File

@ -124,36 +124,7 @@ public:
PRUint32 Serial() const { return mSerial; }
void SetSerial(PRUint32 aIndex) { mSerial = aIndex; }
nsrefcnt AddRef()
{
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsSMILInstanceTime");
return mRefCnt;
}
NS_ASSERT_OWNINGTHREAD(_class);
NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(),
"nsSMILInstanceTime addref isn't thread-safe!");
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsSMILInstanceTime", sizeof(*this));
return mRefCnt;
}
nsrefcnt Release()
{
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsSMILInstanceTime");
return mRefCnt;
}
NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(),
"nsSMILInstanceTime release isn't thread-safe!");
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsSMILInstanceTime");
if (mRefCnt == 0) {
delete this;
return 0;
}
return mRefCnt;
}
NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime)
protected:
void SetBaseInterval(nsSMILInterval* aBaseInterval);
@ -162,9 +133,6 @@ protected:
nsSMILTimeValue mTime;
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
// Internal flags used for represent behaviour of different instance times`
enum {
// Indicates if this instance time should be removed when the owning timed

View File

@ -46,6 +46,7 @@
#include "nsClassHashtable.h"
#include "nsTArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupportsImpl.h"
class nsXBLPrototypeBinding;
class nsIContent;
@ -77,24 +78,7 @@ public:
* which are queued to fire their constructors.
*/
nsrefcnt AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsXBLBinding", sizeof(nsXBLBinding));
return mRefCnt;
}
nsrefcnt Release()
{
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsXBLBinding");
if (mRefCnt == 0) {
mRefCnt = 1;
delete this;
return 0;
}
return mRefCnt;
}
NS_INLINE_DECL_REFCOUNTING(nsXBLBinding)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLBinding)
@ -172,7 +156,6 @@ public:
// MEMBER VARIABLES
protected:
nsAutoRefCnt mRefCnt;
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
nsRefPtr<nsXBLBinding> mNextBinding; // Strong. The derived binding owns the base class bindings.

View File

@ -57,19 +57,6 @@ nsXBLInsertionPoint::~nsXBLInsertionPoint()
}
}
nsrefcnt
nsXBLInsertionPoint::Release()
{
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPoint");
if (mRefCnt == 0) {
mRefCnt = 1;
delete this;
return 0;
}
return mRefCnt;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLInsertionPoint)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXBLInsertionPoint)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mElements)

View File

@ -50,15 +50,7 @@ public:
nsXBLInsertionPoint(nsIContent* aParentElement, PRUint32 aIndex, nsIContent* aDefContent);
~nsXBLInsertionPoint();
nsrefcnt AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPoint",
sizeof(nsXBLInsertionPoint));
return mRefCnt;
}
nsrefcnt Release();
NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPoint)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLInsertionPoint)
@ -90,7 +82,6 @@ public:
void UnbindDefaultContent();
protected:
nsAutoRefCnt mRefCnt;
nsIContent* mParentElement; // This ref is weak. The parent of the <children> element.
PRInt32 mIndex; // The index of this insertion point. -1 is a pseudo-point.
nsCOMArray<nsIContent> mElements; // An array of elements present at the insertion point.

View File

@ -207,27 +207,12 @@ public:
nsXBLInsertionPointEntry::ReleasePool();
}
nsrefcnt AddRef() {
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPointEntry", sizeof(nsXBLInsertionPointEntry));
return mRefCnt;
}
nsrefcnt Release() {
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPointEntry");
if (mRefCnt == 0) {
Destroy(this);
return 0;
}
return mRefCnt;
}
NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPointEntry)
protected:
nsCOMPtr<nsIContent> mInsertionParent;
nsCOMPtr<nsIContent> mDefaultContent;
PRUint32 mInsertionIndex;
nsAutoRefCnt mRefCnt;
nsXBLInsertionPointEntry(nsIContent* aParent)
: mInsertionParent(aParent),

View File

@ -404,14 +404,12 @@ public:
txCompileObserver(txMozillaXSLTProcessor* aProcessor,
nsILoadGroup* aLoadGroup);
TX_DECL_ACOMPILEOBSERVER;
TX_DECL_ACOMPILEOBSERVER
NS_INLINE_DECL_REFCOUNTING(txCompileObserver)
nsresult startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler,
nsIPrincipal* aSourcePrincipal);
protected:
nsAutoRefCnt mRefCnt;
private:
nsRefPtr<txMozillaXSLTProcessor> mProcessor;
nsCOMPtr<nsILoadGroup> mLoadGroup;
@ -429,23 +427,6 @@ txCompileObserver::txCompileObserver(txMozillaXSLTProcessor* aProcessor,
{
}
nsrefcnt
txCompileObserver::AddRef()
{
return ++mRefCnt;
}
nsrefcnt
txCompileObserver::Release()
{
if (--mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
}
return mRefCnt;
}
nsresult
txCompileObserver::loadURI(const nsAString& aUri,
const nsAString& aReferrerUri,
@ -658,11 +639,11 @@ class txSyncCompileObserver : public txACompileObserver
public:
txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor);
TX_DECL_ACOMPILEOBSERVER;
TX_DECL_ACOMPILEOBSERVER
NS_INLINE_DECL_REFCOUNTING(txSyncCompileObserver)
protected:
nsRefPtr<txMozillaXSLTProcessor> mProcessor;
nsAutoRefCnt mRefCnt;
};
txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor)
@ -670,23 +651,6 @@ txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor)
{
}
nsrefcnt
txSyncCompileObserver::AddRef()
{
return ++mRefCnt;
}
nsrefcnt
txSyncCompileObserver::Release()
{
if (--mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
}
return mRefCnt;
}
nsresult
txSyncCompileObserver::loadURI(const nsAString& aUri,
const nsAString& aReferrerUri,

View File

@ -64,7 +64,8 @@ class txDriver : public txACompileObserver
const XML_Char *aSystemId,
const XML_Char *aPublicId);
TX_DECL_ACOMPILEOBSERVER;
TX_DECL_ACOMPILEOBSERVER
NS_INLINE_DECL_REFCOUNTING(txDriver)
nsRefPtr<txStylesheetCompiler> mCompiler;
protected:
@ -73,7 +74,6 @@ class txDriver : public txACompileObserver
// keep track of the nsresult returned by the handlers, expat forgets them
nsresult mRV;
XML_Parser mExpatParser;
nsAutoRefCnt mRefCnt;
};
nsresult
@ -338,23 +338,6 @@ txDriver::createErrorString()
* txACompileObserver implementation
*/
nsrefcnt
txDriver::AddRef()
{
return ++mRefCnt;
}
nsrefcnt
txDriver::Release()
{
if (--mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
}
return mRefCnt;
}
void
txDriver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult,
const PRUnichar *aErrorText, const PRUnichar *aParam)

View File

@ -44,6 +44,7 @@
#include "txList.h"
#include "txXSLTPatterns.h"
#include "nsTPtrArray.h"
#include "nsISupportsImpl.h"
class txInstruction;
class txToplevelItem;
@ -67,20 +68,8 @@ public:
txStylesheet();
~txStylesheet();
nsresult init();
nsrefcnt AddRef()
{
return ++mRefCnt;
}
nsrefcnt Release()
{
if (--mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
}
return mRefCnt;
}
NS_INLINE_DECL_REFCOUNTING(txStylesheet)
txInstruction* findTemplate(const txXPathNode& aNode,
const txExpandedName& aMode,
@ -159,9 +148,6 @@ private:
nsTPtrArray<txStripSpaceTest>& aFrameStripSpaceTests);
nsresult addAttributeSet(txAttributeSetItem* aAttributeSetItem);
// Refcount
nsAutoRefCnt mRefCnt;
// List of ImportFrames
txList mImportFrames;

View File

@ -69,27 +69,6 @@ txStylesheetCompiler::txStylesheetCompiler(const nsAString& aStylesheetURI,
mStatus = init(aStylesheetURI, aStylesheet, aInsertPosition);
}
nsrefcnt
txStylesheetCompiler::AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "txStylesheetCompiler", sizeof(*this));
return mRefCnt;
}
nsrefcnt
txStylesheetCompiler::Release()
{
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "txStylesheetCompiler");
if (mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
}
return mRefCnt;
}
void
txStylesheetCompiler::setBaseURI(const nsString& aBaseURI)
{

View File

@ -77,8 +77,8 @@ public:
class txACompileObserver
{
public:
virtual nsrefcnt AddRef() = 0;
virtual nsrefcnt Release() = 0;
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual nsresult loadURI(const nsAString& aUri,
const nsAString& aReferrerUri,
@ -90,13 +90,11 @@ public:
};
#define TX_DECL_ACOMPILEOBSERVER \
nsrefcnt AddRef(); \
nsrefcnt Release(); \
nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, \
txStylesheetCompiler* aCompiler); \
void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, \
const PRUnichar *aErrorText = nsnull, \
const PRUnichar *aParam = nsnull)
const PRUnichar *aParam = nsnull);
class txStylesheetCompilerState : public txIParseContext
{
@ -215,8 +213,6 @@ public:
txStylesheet* aStylesheet,
txListIterator* aInsertPosition,
txACompileObserver* aObserver);
virtual nsrefcnt AddRef();
virtual nsrefcnt Release();
void setBaseURI(const nsString& aBaseURI);
@ -235,12 +231,8 @@ public:
txStylesheet* getStylesheet();
// txACompileObserver
nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri,
txStylesheetCompiler* aCompiler);
void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult,
const PRUnichar *aErrorText = nsnull,
const PRUnichar *aParam = nsnull);
TX_DECL_ACOMPILEOBSERVER
NS_INLINE_DECL_REFCOUNTING(txStylesheetCompiler)
private:
nsresult startElementInternal(PRInt32 aNamespaceID, nsIAtom* aLocalName,
@ -253,7 +245,6 @@ private:
nsresult ensureNewElementContext();
nsresult maybeDoneCompiling();
nsAutoRefCnt mRefCnt;
nsString mCharacters;
nsresult mStatus;
};

View File

@ -40,6 +40,7 @@
#include "nsAutoPtr.h"
#include "nsIAtom.h"
#include "nsIRDFResource.h"
#include "nsISupportsImpl.h"
class nsXULTemplateResultRDF;
class nsBindingValues;
@ -95,9 +96,6 @@ class RDFBindingSet
{
protected:
// results hold a reference to a binding set in their nsBindingValues fields
PRInt32 mRefCnt;
// the number of bindings
PRInt32 mCount;
@ -107,8 +105,7 @@ protected:
public:
RDFBindingSet()
: mRefCnt(0),
mCount(0),
: mCount(0),
mFirst(nsnull)
{
MOZ_COUNT_CTOR(RDFBindingSet);
@ -116,19 +113,7 @@ public:
~RDFBindingSet();
PRInt32 AddRef() {
mRefCnt++;
NS_LOG_ADDREF(this, mRefCnt, "RDFBindingSet", sizeof(*this));
return mRefCnt;
}
PRInt32 Release()
{
PRInt32 refcnt = --mRefCnt;
NS_LOG_RELEASE(this, refcnt, "RDFBindingSet");
if (refcnt == 0) delete this;
return refcnt;
}
NS_INLINE_DECL_REFCOUNTING(RDFBindingSet)
PRInt32 Count() const { return mCount; }