From e05404b825e9a1909716d7ded71b1727011f1f29 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Tue, 29 Sep 2020 11:40:58 +0000 Subject: [PATCH] Bug 1589337 - Use nsIClassInfoImpl in nsJARURI r=necko-reviewers,kershaw Differential Revision: https://phabricator.services.mozilla.com/D90256 --- modules/libjar/nsJARURI.cpp | 53 ++++------------------------------ modules/libjar/nsJARURI.h | 3 -- netwerk/test/unit/test_URIs.js | 20 ++++++++----- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 401abbd62d93..aa70e94212ea 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -8,6 +8,7 @@ #include "nsJARURI.h" #include "nsNetUtil.h" +#include "nsIClassInfoImpl.h" #include "nsIIOService.h" #include "nsIStandardURL.h" #include "nsCRT.h" @@ -24,6 +25,10 @@ static NS_DEFINE_CID(kJARURICID, NS_JARURI_CID); //////////////////////////////////////////////////////////////////////////////// +NS_IMPL_CLASSINFO(nsJARURI, nullptr, nsIClassInfo::THREADSAFE, NS_JARURI_CID) +// Empty CI getter. We only need nsIClassInfo for Serialization +NS_IMPL_CI_INTERFACE_GETTER0(nsJARURI) + nsJARURI::nsJARURI() {} nsJARURI::~nsJARURI() {} @@ -37,7 +42,7 @@ NS_INTERFACE_MAP_BEGIN(nsJARURI) NS_INTERFACE_MAP_ENTRY(nsIURL) NS_INTERFACE_MAP_ENTRY(nsIJARURI) NS_INTERFACE_MAP_ENTRY(nsISerializable) - NS_INTERFACE_MAP_ENTRY(nsIClassInfo) + NS_IMPL_QUERY_CLASSINFO(nsJARURI) NS_INTERFACE_MAP_ENTRY(nsINestedURI) NS_INTERFACE_MAP_ENTRY_CONCRETE(nsJARURI) NS_INTERFACE_MAP_END @@ -128,52 +133,6 @@ nsJARURI::Write(nsIObjectOutputStream* aOutputStream) { return rv; } -//////////////////////////////////////////////////////////////////////////////// -// nsIClassInfo methods: - -NS_IMETHODIMP -nsJARURI::GetInterfaces(nsTArray& array) { - array.Clear(); - return NS_OK; -} - -NS_IMETHODIMP -nsJARURI::GetScriptableHelper(nsIXPCScriptable** _retval) { - *_retval = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -nsJARURI::GetContractID(nsACString& aContractID) { - aContractID.SetIsVoid(true); - return NS_OK; -} - -NS_IMETHODIMP -nsJARURI::GetClassDescription(nsACString& aClassDescription) { - aClassDescription.SetIsVoid(true); - return NS_OK; -} - -NS_IMETHODIMP -nsJARURI::GetClassID(nsCID** aClassID) { - *aClassID = (nsCID*)moz_xmalloc(sizeof(nsCID)); - return GetClassIDNoAlloc(*aClassID); -} - -NS_IMETHODIMP -nsJARURI::GetFlags(uint32_t* aFlags) { - // XXX We implement THREADSAFE addref/release, but probably shouldn't. - *aFlags = nsIClassInfo::MAIN_THREAD_ONLY; - return NS_OK; -} - -NS_IMETHODIMP -nsJARURI::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) { - *aClassIDNoAlloc = kJARURICID; - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// // nsIURI methods: diff --git a/modules/libjar/nsJARURI.h b/modules/libjar/nsJARURI.h index fc42076a3765..7be600f0216a 100644 --- a/modules/libjar/nsJARURI.h +++ b/modules/libjar/nsJARURI.h @@ -9,7 +9,6 @@ #include "nsIJARURI.h" #include "nsISerializable.h" -#include "nsIClassInfo.h" #include "nsCOMPtr.h" #include "nsString.h" #include "nsINestedURI.h" @@ -38,7 +37,6 @@ class nsJARURI final : public nsIJARURI, public nsISerializable, - public nsIClassInfo, public nsINestedURI { public: NS_DECL_THREADSAFE_ISUPPORTS @@ -46,7 +44,6 @@ class nsJARURI final : public nsIJARURI, NS_DECL_NSIURL NS_DECL_NSIJARURI NS_DECL_NSISERIALIZABLE - NS_DECL_NSICLASSINFO NS_DECL_NSINESTEDURI NS_DECLARE_STATIC_IID_ACCESSOR(NS_THIS_JARURI_IMPL_CID) diff --git a/netwerk/test/unit/test_URIs.js b/netwerk/test/unit/test_URIs.js index db12188e64d8..df55ebe1572e 100644 --- a/netwerk/test/unit/test_URIs.js +++ b/netwerk/test/unit/test_URIs.js @@ -1015,6 +1015,14 @@ add_task(function mainTest() { }); }); +function check_round_trip_serialization(spec) { + dump(`checking ${spec}\n`); + let uri = gIoService.newURI(spec); + let str = serialize_to_escaped_string(uri); + let other = deserialize_from_escaped_string(str).QueryInterface(Ci.nsIURI); + equal(other.spec, uri.spec); +} + add_task(function test_iconURI_serialization() { // URIs taken from test_moz_icon_uri.js @@ -1026,13 +1034,9 @@ add_task(function test_iconURI_serialization() { "moz-icon://file://foo.txt", ]; - function check_round_trip_serialization(spec) { - dump(`checking ${spec}\n`); - let uri = gIoService.newURI(spec); - let str = serialize_to_escaped_string(uri); - let other = deserialize_from_escaped_string(str).QueryInterface(Ci.nsIURI); - equal(other.spec, uri.spec); - } - tests.forEach(str => check_round_trip_serialization(str)); }); + +add_task(function test_jarURI_serialization() { + check_round_trip_serialization("jar:http://example.com/bar.jar!/"); +});