Bug 931283, part 3 - Implement a cycle collected version of nsVariant. r=froydnj

Also, use this class for the component manager etc. in XPCOM.
This commit is contained in:
Andrew McCreight 2015-10-09 10:24:23 -07:00
parent 642c4344e2
commit c97953414d
4 changed files with 36 additions and 4 deletions

View File

@ -213,7 +213,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVersionComparatorImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableBase64Encoder)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariantCC)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHashPropertyBagCC)

View File

@ -57,7 +57,7 @@
COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor)
COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor)
COMPONENT(VARIANT, nsVariantConstructor)
COMPONENT(VARIANT, nsVariantCCConstructor)
COMPONENT(INTERFACEINFOMANAGER_SERVICE, nsXPTIInterfaceInfoManagerGetSingleton)
COMPONENT(HASH_PROPERTY_BAG, nsHashPropertyBagCCConstructor)

View File

@ -2178,3 +2178,24 @@ nsVariantBase::SetFromVariant(nsIVariant* aValue)
/* nsVariant implementation */
NS_IMPL_ISUPPORTS(nsVariant, nsIVariant, nsIWritableVariant)
/* nsVariantCC implementation */
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsVariantCC)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIVariant)
NS_INTERFACE_MAP_ENTRY(nsIWritableVariant)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_CLASS(nsVariantCC)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsVariantCC)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsVariantCC)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsVariantCC)
tmp->mData.Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsVariantCC)
tmp->mData.Cleanup();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

View File

@ -10,8 +10,7 @@
#include "nsIVariant.h"
#include "nsStringFwd.h"
#include "mozilla/Attributes.h"
class nsCycleCollectionTraversalCallback;
#include "nsCycleCollectionParticipant.h"
/**
* Map the nsAUTF8String, nsUTF8String classes to the nsACString and
@ -200,6 +199,18 @@ private:
~nsVariant() {};
};
class nsVariantCC final : public nsVariantBase
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsVariantCC)
nsVariantCC() {};
private:
~nsVariantCC() {};
};
/**
* Users of nsIVariant should be using the contractID and not this CID.
* - see NS_VARIANT_CONTRACTID in nsIVariant.idl.