Bug 1589337 - Use nsIClassInfoImpl in nsSimpleURI and children r=necko-reviewers,kershaw,xpcom-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D90257
This commit is contained in:
Valentin Gosu 2020-09-29 11:41:26 +00:00
Родитель e05404b825
Коммит cf8a03778f
11 изменённых файлов: 51 добавлений и 148 удалений

Просмотреть файл

@ -4,6 +4,7 @@
* 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/. */
#include "nsIClassInfoImpl.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
@ -22,6 +23,11 @@ static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_IMPL_ADDREF_INHERITED(BlobURL, mozilla::net::nsSimpleURI)
NS_IMPL_RELEASE_INHERITED(BlobURL, mozilla::net::nsSimpleURI)
NS_IMPL_CLASSINFO(BlobURL, nullptr, nsIClassInfo::THREADSAFE,
NS_HOSTOBJECTURI_CID);
// Empty CI getter. We only need nsIClassInfo for Serialization
NS_IMPL_CI_INTERFACE_GETTER0(BlobURL)
NS_INTERFACE_MAP_BEGIN(BlobURL)
if (aIID.Equals(kHOSTOBJECTURICID))
foundInterface = static_cast<nsIURI*>(this);
@ -32,6 +38,7 @@ NS_INTERFACE_MAP_BEGIN(BlobURL)
*aInstancePtr = nullptr;
return NS_NOINTERFACE;
} else
NS_IMPL_QUERY_CLASSINFO(BlobURL)
NS_INTERFACE_MAP_END_INHERITING(mozilla::net::nsSimpleURI)
BlobURL::BlobURL() : mRevoked(false) {}
@ -164,51 +171,3 @@ BlobURL::Mutate(nsIURIMutator** aMutator) {
mutator.forget(aMutator);
return NS_OK;
}
// nsIClassInfo methods:
NS_IMETHODIMP
BlobURL::GetInterfaces(nsTArray<nsIID>& array) {
array.Clear();
return NS_OK;
}
NS_IMETHODIMP
BlobURL::GetScriptableHelper(nsIXPCScriptable** _retval) {
*_retval = nullptr;
return NS_OK;
}
NS_IMETHODIMP
BlobURL::GetContractID(nsACString& aContractID) {
// Make sure to modify any subclasses as needed if this ever
// changes.
aContractID.SetIsVoid(true);
return NS_OK;
}
NS_IMETHODIMP
BlobURL::GetClassDescription(nsACString& aClassDescription) {
aClassDescription.SetIsVoid(true);
return NS_OK;
}
NS_IMETHODIMP
BlobURL::GetClassID(nsCID** aClassID) {
// Make sure to modify any subclasses as needed if this ever
// changes to not call the virtual GetClassIDNoAlloc.
*aClassID = (nsCID*)moz_xmalloc(sizeof(nsCID));
return GetClassIDNoAlloc(*aClassID);
}
NS_IMETHODIMP
BlobURL::GetFlags(uint32_t* aFlags) {
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
return NS_OK;
}
NS_IMETHODIMP
BlobURL::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) {
*aClassIDNoAlloc = kHOSTOBJECTURICID;
return NS_OK;
}

Просмотреть файл

@ -40,7 +40,6 @@ class BlobURL final : public mozilla::net::nsSimpleURI {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
// Override CloneInternal() and EqualsInternal()
virtual nsresult CloneInternal(RefHandlingEnum aRefHandlingMode,

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsStringStream.h"
#include "nsNetUtil.h"
#include "nsIClassInfoImpl.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsIScriptContext.h"
@ -1206,6 +1207,10 @@ static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_IMPL_ADDREF_INHERITED(nsJSURI, mozilla::net::nsSimpleURI)
NS_IMPL_RELEASE_INHERITED(nsJSURI, mozilla::net::nsSimpleURI)
NS_IMPL_CLASSINFO(nsJSURI, nullptr, nsIClassInfo::THREADSAFE, NS_JSURI_CID);
// Empty CI getter. We only need nsIClassInfo for Serialization
NS_IMPL_CI_INTERFACE_GETTER0(nsJSURI)
NS_INTERFACE_MAP_BEGIN(nsJSURI)
if (aIID.Equals(kJSURICID))
foundInterface = static_cast<nsIURI*>(this);
@ -1216,6 +1221,7 @@ NS_INTERFACE_MAP_BEGIN(nsJSURI)
*aInstancePtr = nullptr;
return NS_NOINTERFACE;
} else
NS_IMPL_QUERY_CLASSINFO(nsJSURI)
NS_INTERFACE_MAP_END_INHERITING(mozilla::net::nsSimpleURI)
// nsISerializable methods:
@ -1353,9 +1359,3 @@ nsresult nsJSURI::EqualsInternal(
*aResult = !otherBaseURI;
return NS_OK;
}
NS_IMETHODIMP
nsJSURI::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) {
*aClassIDNoAlloc = kJSURICID;
return NS_OK;
}

Просмотреть файл

@ -77,12 +77,6 @@ class nsJSURI final : public mozilla::net::nsSimpleURI {
NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
// Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
// nsISerializable impl works right.
NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) override;
// NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr )
// override;
protected:
nsJSURI() = default;
explicit nsJSURI(nsIURI* aBaseURI) : mBaseURI(aBaseURI) {}

Просмотреть файл

@ -16,7 +16,15 @@
namespace mozilla {
namespace net {
NS_IMPL_ISUPPORTS_INHERITED(nsSimpleNestedURI, nsSimpleURI, nsINestedURI)
NS_IMPL_CLASSINFO(nsSimpleNestedURI, nullptr, nsIClassInfo::THREADSAFE,
NS_SIMPLENESTEDURI_CID)
// Empty CI getter. We only need nsIClassInfo for Serialization
NS_IMPL_CI_INTERFACE_GETTER0(nsSimpleNestedURI)
NS_IMPL_ADDREF_INHERITED(nsSimpleNestedURI, nsSimpleURI)
NS_IMPL_RELEASE_INHERITED(nsSimpleNestedURI, nsSimpleURI)
NS_IMPL_QUERY_INTERFACE_CI_INHERITED(nsSimpleNestedURI, nsSimpleURI,
nsINestedURI)
nsSimpleNestedURI::nsSimpleNestedURI(nsIURI* innerURI) : mInnerURI(innerURI) {
NS_ASSERTION(innerURI, "Must have inner URI");
@ -199,16 +207,6 @@ nsSimpleURI* nsSimpleNestedURI::StartClone(
return url;
}
// nsIClassInfo overrides
NS_IMETHODIMP
nsSimpleNestedURI::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) {
static NS_DEFINE_CID(kSimpleNestedURICID, NS_SIMPLENESTEDURI_CID);
*aClassIDNoAlloc = kSimpleNestedURICID;
return NS_OK;
}
// Queries this list of interfaces. If none match, it queries mURI.
NS_IMPL_NSIURIMUTATOR_ISUPPORTS(nsSimpleNestedURI::Mutator, nsIURISetters,
nsIURIMutator, nsISerializable,

Просмотреть файл

@ -46,10 +46,6 @@ class nsSimpleNestedURI : public nsSimpleURI, public nsINestedURI {
NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
// Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
// nsISerializable impl works right.
NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) override;
protected:
nsCOMPtr<nsIURI> mInnerURI;

Просмотреть файл

@ -21,6 +21,7 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/TextUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "nsIClassInfoImpl.h"
#include "nsIURIMutator.h"
#include "mozilla/net/MozURL.h"
@ -31,7 +32,6 @@ namespace net {
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
/* static */
already_AddRefed<nsSimpleURI> nsSimpleURI::From(nsIURI* aURI) {
@ -45,6 +45,11 @@ already_AddRefed<nsSimpleURI> nsSimpleURI::From(nsIURI* aURI) {
return uri.forget();
}
NS_IMPL_CLASSINFO(nsSimpleURI, nullptr, nsIClassInfo::THREADSAFE,
NS_SIMPLEURI_CID)
// Empty CI getter. We only need nsIClassInfo for Serialization
NS_IMPL_CI_INTERFACE_GETTER0(nsSimpleURI)
////////////////////////////////////////////////////////////////////////////////
// nsSimpleURI methods:
@ -53,8 +58,9 @@ nsSimpleURI::nsSimpleURI() : mIsRefValid(false), mIsQueryValid(false) {}
NS_IMPL_ADDREF(nsSimpleURI)
NS_IMPL_RELEASE(nsSimpleURI)
NS_INTERFACE_TABLE_HEAD(nsSimpleURI)
NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsISerializable, nsIClassInfo)
NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsISerializable)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
NS_IMPL_QUERY_CLASSINFO(nsSimpleURI)
if (aIID.Equals(kThisSimpleURIImplementationCID))
foundInterface = static_cast<nsIURI*>(this);
else
@ -638,56 +644,6 @@ nsSimpleURI::GetAsciiHost(nsACString& result) {
return NS_OK;
}
//----------------------------------------------------------------------------
// nsSimpleURI::nsIClassInfo
//----------------------------------------------------------------------------
NS_IMETHODIMP
nsSimpleURI::GetInterfaces(nsTArray<nsIID>& array) {
array.Clear();
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetScriptableHelper(nsIXPCScriptable** _retval) {
*_retval = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetContractID(nsACString& aContractID) {
// Make sure to modify any subclasses as needed if this ever
// changes.
aContractID.SetIsVoid(true);
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetClassDescription(nsACString& aClassDescription) {
aClassDescription.SetIsVoid(true);
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetClassID(nsCID** aClassID) {
// Make sure to modify any subclasses as needed if this ever
// changes to not call the virtual GetClassIDNoAlloc.
*aClassID = (nsCID*)moz_xmalloc(sizeof(nsCID));
return GetClassIDNoAlloc(*aClassID);
}
NS_IMETHODIMP
nsSimpleURI::GetFlags(uint32_t* aFlags) {
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) {
*aClassIDNoAlloc = kSimpleURICID;
return NS_OK;
}
//----------------------------------------------------------------------------
// nsSimpleURI::nsISizeOf
//----------------------------------------------------------------------------

Просмотреть файл

@ -24,10 +24,7 @@ namespace net {
} \
}
class nsSimpleURI : public nsIURI,
public nsISerializable,
public nsIClassInfo,
public nsISizeOf {
class nsSimpleURI : public nsIURI, public nsISerializable, public nsISizeOf {
protected:
nsSimpleURI();
virtual ~nsSimpleURI() = default;
@ -36,7 +33,6 @@ class nsSimpleURI : public nsIURI,
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
static already_AddRefed<nsSimpleURI> From(nsIURI* aURI);

Просмотреть файл

@ -20,6 +20,7 @@
#include "nsIChannel.h"
#include "nsIScriptError.h"
#include "nsIEnterprisePolicies.h"
#include "nsIClassInfoImpl.h"
#include "mozilla/ipc/URIUtils.h"
@ -338,10 +339,17 @@ nsSafeAboutProtocolHandler::AllowPort(int32_t port, const char* scheme,
////////////////////////////////////////////////////////////
// nsNestedAboutURI implementation
NS_IMPL_CLASSINFO(nsNestedAboutURI, nullptr, nsIClassInfo::THREADSAFE,
NS_NESTEDABOUTURI_CID);
// Empty CI getter. We only need nsIClassInfo for Serialization
NS_IMPL_CI_INTERFACE_GETTER0(nsNestedAboutURI)
NS_INTERFACE_MAP_BEGIN(nsNestedAboutURI)
if (aIID.Equals(kNestedAboutURICID))
foundInterface = static_cast<nsIURI*>(this);
else
NS_IMPL_QUERY_CLASSINFO(nsNestedAboutURI)
NS_INTERFACE_MAP_END_INHERITING(nsSimpleNestedURI)
// nsISerializable
@ -477,12 +485,5 @@ nsNestedAboutURI::Mutate(nsIURIMutator** aMutator) {
return NS_OK;
}
// nsIClassInfo
NS_IMETHODIMP
nsNestedAboutURI::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) {
*aClassIDNoAlloc = kNestedAboutURICID;
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -65,8 +65,6 @@ class nsNestedAboutURI final : public nsSimpleNestedURI {
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
// Override StartClone(), the nsISerializable methods, and
// GetClassIDNoAlloc; this last is needed to make our nsISerializable impl
// work right.
virtual nsSimpleURI* StartClone(RefHandlingEnum aRefHandlingMode,
const nsACString& newRef) override;
NS_IMETHOD Mutate(nsIURIMutator** _retval) override;
@ -76,10 +74,6 @@ class nsNestedAboutURI final : public nsSimpleNestedURI {
NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
// Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
// nsISerializable impl works right.
NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) override;
nsIURI* GetBaseURI() const { return mBaseURI; }
protected:

Просмотреть файл

@ -159,15 +159,25 @@ class GenericClassInfo : public nsIClassInfo {
NS_CLASSINFO_HELPER_BEGIN(aClass, 0) \
NS_CLASSINFO_HELPER_END
#define NS_IMPL_QUERY_INTERFACE_CI(aClass, ...) \
// Note that this macro is an internal implementation of this header and
// should not be used outside it. It does not end the interface map as this
// is done in NS_IMPL_QUERY_INTERFACE_CI or the _INHERITED variant.
#define NS_IMPL_QUERY_INTERFACE_CI_GUTS(aClass, ...) \
static_assert(MOZ_ARG_COUNT(__VA_ARGS__) > 0, \
"Need more arguments to NS_IMPL_QUERY_INTERFACE_CI"); \
NS_INTERFACE_MAP_BEGIN(aClass) \
MOZ_FOR_EACH(NS_INTERFACE_MAP_ENTRY, (), (__VA_ARGS__)) \
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, MOZ_ARG_1(__VA_ARGS__)) \
NS_IMPL_QUERY_CLASSINFO(aClass) \
NS_IMPL_QUERY_CLASSINFO(aClass)
#define NS_IMPL_QUERY_INTERFACE_CI(aClass, ...) \
NS_IMPL_QUERY_INTERFACE_CI_GUTS(aClass, __VA_ARGS__) \
NS_INTERFACE_MAP_END
#define NS_IMPL_QUERY_INTERFACE_CI_INHERITED(aClass, aSuper, ...) \
NS_IMPL_QUERY_INTERFACE_CI_GUTS(aClass, __VA_ARGS__) \
NS_INTERFACE_MAP_END_INHERITING(aSuper)
#define NS_IMPL_ISUPPORTS_CI(aClass, ...) \
NS_IMPL_ADDREF(aClass) \
NS_IMPL_RELEASE(aClass) \