Bug 1530685 - Part 3: Remove nsIJARProtocolHandler; r=valentin
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 26 Feb 2019 15:29:37 +0000
changeset 519112 3113a6f2e2c35cba3f14e69602f6fdb6726b0e57
parent 519111 b44a6076d5835f63480e2e65fa855865886fe633
child 519113 ec6c7dcf2f315c17d913553bbf0654c091d2622f
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1530685
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
modules/libjar/moz.build
modules/libjar/nsIJARProtocolHandler.idl
modules/libjar/nsJARChannel.cpp
modules/libjar/nsJARProtocolHandler.cpp
modules/libjar/nsJARProtocolHandler.h
toolkit/mozapps/extensions/AddonManagerStartup.cpp
--- a/modules/libjar/moz.build
+++ b/modules/libjar/moz.build
@@ -11,24 +11,24 @@ if CONFIG['MOZ_ZIPWRITER']:
     DIRS += ['zipwriter']
 
 MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
 
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 XPIDL_SOURCES += [
     'nsIJARChannel.idl',
-    'nsIJARProtocolHandler.idl',
     'nsIJARURI.idl',
     'nsIZipReader.idl',
 ]
 
 XPIDL_MODULE = 'jar'
 
 EXPORTS += [
+    'nsJARProtocolHandler.h',
     'nsJARURI.h',
     'nsZipArchive.h',
     'zipstruct.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsJAR.cpp',
     'nsJARChannel.cpp',
deleted file mode 100644
--- 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;
-};
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -22,16 +22,17 @@
 #include "nsIFileURL.h"
 
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsITabChild.h"
 #include "private/pprio.h"
 #include "nsInputStreamPump.h"
 #include "nsThreadUtils.h"
+#include "nsJARProtocolHandler.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
 // the entry for a directory will either be empty (in the case of the
 // top-level directory) or will end with a slash
@@ -944,22 +945,20 @@ nsJARChannel::EnsureCached(bool *aIsCach
 
   nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIProtocolHandler> handler;
   rv = ioService->GetProtocolHandler("jar", getter_AddRefs(handler));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIJARProtocolHandler> jarHandler = do_QueryInterface(handler);
+  auto jarHandler = static_cast<nsJARProtocolHandler *>(handler.get());
   MOZ_ASSERT(jarHandler);
 
-  nsCOMPtr<nsIZipReaderCache> 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) {
     return NS_OK;
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aIsCached = true;
--- a/modules/libjar/nsJARProtocolHandler.cpp
+++ b/modules/libjar/nsJARProtocolHandler.cpp
@@ -42,38 +42,31 @@ nsresult nsJARProtocolHandler::Init() {
 }
 
 nsIMIMEService *nsJARProtocolHandler::MimeService() {
   if (!mMimeService) mMimeService = do_GetService("@mozilla.org/mime;1");
 
   return mMimeService.get();
 }
 
-NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIJARProtocolHandler,
-                  nsIProtocolHandler, nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIProtocolHandler,
+                  nsISupportsWeakReference)
 
 already_AddRefed<nsJARProtocolHandler> nsJARProtocolHandler::GetSingleton() {
   if (!gJarHandler) {
     gJarHandler = new nsJARProtocolHandler();
     if (NS_SUCCEEDED(gJarHandler->Init())) {
       ClearOnShutdown(&gJarHandler);
     } else {
       gJarHandler = nullptr;
     }
   }
   return do_AddRef(gJarHandler);
 }
 
-NS_IMETHODIMP
-nsJARProtocolHandler::GetJARCache(nsIZipReaderCache **result) {
-  *result = mJARCache;
-  NS_ADDREF(*result);
-  return NS_OK;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsIProtocolHandler methods:
 
 NS_IMETHODIMP
 nsJARProtocolHandler::GetScheme(nsACString &result) {
   result.AssignLiteral("jar");
   return NS_OK;
 }
--- a/modules/libjar/nsJARProtocolHandler.h
+++ b/modules/libjar/nsJARProtocolHandler.h
@@ -2,41 +2,39 @@
 /* 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/. */
 
 #ifndef nsJARProtocolHandler_h__
 #define nsJARProtocolHandler_h__
 
 #include "mozilla/StaticPtr.h"
-#include "nsIJARProtocolHandler.h"
 #include "nsIProtocolHandler.h"
 #include "nsIJARURI.h"
 #include "nsIZipReader.h"
 #include "nsIMIMEService.h"
 #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();
 
   static already_AddRefed<nsJARProtocolHandler> GetSingleton();
 
   nsresult Init();
 
   // returns non addref'ed pointer.
   nsIMIMEService *MimeService();
-  nsIZipReaderCache *JarCache() { return mJARCache; }
+  nsIZipReaderCache *JarCache() const { return mJARCache; }
 
  protected:
   virtual ~nsJARProtocolHandler();
 
   nsCOMPtr<nsIZipReaderCache> mJARCache;
   nsCOMPtr<nsIMIMEService> mMimeService;
 };
 
--- a/toolkit/mozapps/extensions/AddonManagerStartup.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerStartup.cpp
@@ -27,20 +27,20 @@
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsAppRunner.h"
 #include "nsContentUtils.h"
 #include "nsChromeRegistry.h"
 #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"
 
 #include <stdlib.h>
 
 namespace mozilla {
 
@@ -186,22 +186,20 @@ static bool ParseJSON(JSContext* cx, nsA
 
 static Result<nsCOMPtr<nsIZipReaderCache>, nsresult> GetJarCache() {
   nsCOMPtr<nsIIOService> ios = services::GetIOService();
   NS_ENSURE_TRUE(ios, Err(NS_ERROR_FAILURE));
 
   nsCOMPtr<nsIProtocolHandler> jarProto;
   MOZ_TRY(ios->GetProtocolHandler("jar", getter_AddRefs(jarProto)));
 
-  nsCOMPtr<nsIJARProtocolHandler> jar = do_QueryInterface(jarProto);
+  auto jar = static_cast<nsJARProtocolHandler*>(jarProto.get());
   MOZ_ASSERT(jar);
 
-  nsCOMPtr<nsIZipReaderCache> zipCache;
-  MOZ_TRY(jar->GetJARCache(getter_AddRefs(zipCache)));
-
+  nsCOMPtr<nsIZipReaderCache> zipCache = jar->JarCache();
   return std::move(zipCache);
 }
 
 static Result<FileLocation, nsresult> GetFileLocation(nsIURI* uri) {
   FileLocation location;
 
   nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
   nsCOMPtr<nsIFile> file;