From f300d392ff4dab568e617a16b5ecbacc9d9626dc Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 26 Feb 2019 15:29:37 +0000 Subject: [PATCH] Bug 1530685 - Part 3: Remove nsIJARProtocolHandler; r=valentin This is an unneeded scriptable interface. Since we no longer have XPCOM add-ons, we can know statically that nsJARProtocolHandler will be handling the jar protocol, so there is no need for ascertaining this at runtime. Depends on D21223 Differential Revision: https://phabricator.services.mozilla.com/D21224 --HG-- extra : moz-landing-system : lando --- modules/libjar/moz.build | 2 +- modules/libjar/nsIJARProtocolHandler.idl | 17 ----------------- modules/libjar/nsJARChannel.cpp | 7 +++---- modules/libjar/nsJARProtocolHandler.cpp | 11 ++--------- modules/libjar/nsJARProtocolHandler.h | 6 ++---- .../mozapps/extensions/AddonManagerStartup.cpp | 8 +++----- 6 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 modules/libjar/nsIJARProtocolHandler.idl diff --git a/modules/libjar/moz.build b/modules/libjar/moz.build index 3f6777633968..0055e5012b8a 100644 --- a/modules/libjar/moz.build +++ b/modules/libjar/moz.build @@ -16,7 +16,6 @@ XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] XPIDL_SOURCES += [ 'nsIJARChannel.idl', - 'nsIJARProtocolHandler.idl', 'nsIJARURI.idl', 'nsIZipReader.idl', ] @@ -24,6 +23,7 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'jar' EXPORTS += [ + 'nsJARProtocolHandler.h', 'nsJARURI.h', 'nsZipArchive.h', 'zipstruct.h', diff --git a/modules/libjar/nsIJARProtocolHandler.idl b/modules/libjar/nsIJARProtocolHandler.idl deleted file mode 100644 index a00239a48bed..000000000000 --- a/modules/libjar/nsIJARProtocolHandler.idl +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* 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/. */ - -#include "nsIProtocolHandler.idl" - -interface nsIZipReaderCache; - -[scriptable, uuid(92c3b42c-98c4-11d3-8cd9-0060b0fc14a3)] -interface nsIJARProtocolHandler : nsIProtocolHandler { - - /** - * JARCache contains the collection of open jar files. - */ - readonly attribute nsIZipReaderCache JARCache; -}; diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index ee2e7c18b21f..dab46f205e5c 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -27,6 +27,7 @@ #include "private/pprio.h" #include "nsInputStreamPump.h" #include "nsThreadUtils.h" +#include "nsJARProtocolHandler.h" using namespace mozilla; using namespace mozilla::net; @@ -949,12 +950,10 @@ nsJARChannel::EnsureCached(bool *aIsCached) { rv = ioService->GetProtocolHandler("jar", getter_AddRefs(handler)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr jarHandler = do_QueryInterface(handler); + auto jarHandler = static_cast(handler.get()); MOZ_ASSERT(jarHandler); - nsCOMPtr jarCache; - rv = jarHandler->GetJARCache(getter_AddRefs(jarCache)); - NS_ENSURE_SUCCESS(rv, rv); + nsIZipReaderCache *jarCache = jarHandler->JarCache(); rv = jarCache->GetZipIfCached(jarFile, getter_AddRefs(mPreCachedJarReader)); if (rv == NS_ERROR_CACHE_KEY_NOT_FOUND) { diff --git a/modules/libjar/nsJARProtocolHandler.cpp b/modules/libjar/nsJARProtocolHandler.cpp index 0289c7284406..86dd2cf8835f 100644 --- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -47,8 +47,8 @@ nsIMIMEService *nsJARProtocolHandler::MimeService() { return mMimeService.get(); } -NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIJARProtocolHandler, - nsIProtocolHandler, nsISupportsWeakReference) +NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIProtocolHandler, + nsISupportsWeakReference) already_AddRefed nsJARProtocolHandler::GetSingleton() { if (!gJarHandler) { @@ -62,13 +62,6 @@ already_AddRefed nsJARProtocolHandler::GetSingleton() { return do_AddRef(gJarHandler); } -NS_IMETHODIMP -nsJARProtocolHandler::GetJARCache(nsIZipReaderCache **result) { - *result = mJARCache; - NS_ADDREF(*result); - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// // nsIProtocolHandler methods: diff --git a/modules/libjar/nsJARProtocolHandler.h b/modules/libjar/nsJARProtocolHandler.h index df112f0f56a9..ad617c7b24ae 100644 --- a/modules/libjar/nsJARProtocolHandler.h +++ b/modules/libjar/nsJARProtocolHandler.h @@ -7,7 +7,6 @@ #define nsJARProtocolHandler_h__ #include "mozilla/StaticPtr.h" -#include "nsIJARProtocolHandler.h" #include "nsIProtocolHandler.h" #include "nsIJARURI.h" #include "nsIZipReader.h" @@ -15,12 +14,11 @@ #include "nsWeakReference.h" #include "nsCOMPtr.h" -class nsJARProtocolHandler final : public nsIJARProtocolHandler, +class nsJARProtocolHandler final : public nsIProtocolHandler, public nsSupportsWeakReference { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER - NS_DECL_NSIJARPROTOCOLHANDLER // nsJARProtocolHandler methods: nsJARProtocolHandler(); @@ -31,7 +29,7 @@ class nsJARProtocolHandler final : public nsIJARProtocolHandler, // returns non addref'ed pointer. nsIMIMEService *MimeService(); - nsIZipReaderCache *JarCache() { return mJARCache; } + nsIZipReaderCache *JarCache() const { return mJARCache; } protected: virtual ~nsJARProtocolHandler(); diff --git a/toolkit/mozapps/extensions/AddonManagerStartup.cpp b/toolkit/mozapps/extensions/AddonManagerStartup.cpp index d653ec477342..ed8c183a6efe 100644 --- a/toolkit/mozapps/extensions/AddonManagerStartup.cpp +++ b/toolkit/mozapps/extensions/AddonManagerStartup.cpp @@ -32,10 +32,10 @@ #include "nsIDOMWindowUtils.h" // for nsIJSRAIIHelper #include "nsIFileURL.h" #include "nsIIOService.h" -#include "nsIJARProtocolHandler.h" #include "nsIJARURI.h" #include "nsIStringEnumerator.h" #include "nsIZipReader.h" +#include "nsJARProtocolHandler.h" #include "nsJSUtils.h" #include "nsReadableUtils.h" #include "nsXULAppAPI.h" @@ -191,12 +191,10 @@ static Result, nsresult> GetJarCache() { nsCOMPtr jarProto; MOZ_TRY(ios->GetProtocolHandler("jar", getter_AddRefs(jarProto))); - nsCOMPtr jar = do_QueryInterface(jarProto); + auto jar = static_cast(jarProto.get()); MOZ_ASSERT(jar); - nsCOMPtr zipCache; - MOZ_TRY(jar->GetJARCache(getter_AddRefs(zipCache))); - + nsCOMPtr zipCache = jar->JarCache(); return std::move(zipCache); }