michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsJARProtocolHandler_h__ michael@0: #define nsJARProtocolHandler_h__ michael@0: michael@0: #include "nsIJARProtocolHandler.h" michael@0: #include "nsIProtocolHandler.h" michael@0: #include "nsIJARURI.h" michael@0: #include "nsIZipReader.h" michael@0: #include "nsIMIMEService.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsClassHashtable.h" michael@0: #include "nsHashKeys.h" michael@0: michael@0: class nsIHashable; michael@0: class nsIRemoteOpenFileListener; michael@0: template class nsAutoTArray; michael@0: michael@0: class nsJARProtocolHandler : public nsIJARProtocolHandler michael@0: , public nsSupportsWeakReference michael@0: { michael@0: typedef nsAutoTArray, 5> michael@0: RemoteFileListenerArray; michael@0: michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIPROTOCOLHANDLER michael@0: NS_DECL_NSIJARPROTOCOLHANDLER michael@0: michael@0: // nsJARProtocolHandler methods: michael@0: nsJARProtocolHandler(); michael@0: virtual ~nsJARProtocolHandler(); michael@0: michael@0: static nsJARProtocolHandler *GetSingleton(); michael@0: michael@0: nsresult Init(); michael@0: michael@0: // returns non addref'ed pointer. michael@0: nsIMIMEService *MimeService(); michael@0: nsIZipReaderCache *JarCache() { return mJARCache; } michael@0: michael@0: bool IsMainProcess() const { return mIsMainProcess; } michael@0: michael@0: bool RemoteOpenFileInProgress(nsIHashable *aRemoteFile, michael@0: nsIRemoteOpenFileListener *aListener); michael@0: void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus); michael@0: michael@0: protected: michael@0: nsCOMPtr mJARCache; michael@0: nsCOMPtr mMimeService; michael@0: michael@0: // Holds lists of RemoteOpenFileChild (not including the 1st) that have michael@0: // requested the same file from parent. michael@0: nsClassHashtable michael@0: mRemoteFileListeners; michael@0: michael@0: bool mIsMainProcess; michael@0: }; michael@0: michael@0: extern nsJARProtocolHandler *gJarHandler; michael@0: michael@0: #define NS_JARPROTOCOLHANDLER_CID \ michael@0: { /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */ \ michael@0: 0xc7e410d4, \ michael@0: 0x85f2, \ michael@0: 0x11d3, \ michael@0: {0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \ michael@0: } michael@0: michael@0: #endif // !nsJARProtocolHandler_h__