Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsJARProtocolHandler_h__ |
michael@0 | 7 | #define nsJARProtocolHandler_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIJARProtocolHandler.h" |
michael@0 | 10 | #include "nsIProtocolHandler.h" |
michael@0 | 11 | #include "nsIJARURI.h" |
michael@0 | 12 | #include "nsIZipReader.h" |
michael@0 | 13 | #include "nsIMIMEService.h" |
michael@0 | 14 | #include "nsWeakReference.h" |
michael@0 | 15 | #include "nsCOMPtr.h" |
michael@0 | 16 | #include "nsClassHashtable.h" |
michael@0 | 17 | #include "nsHashKeys.h" |
michael@0 | 18 | |
michael@0 | 19 | class nsIHashable; |
michael@0 | 20 | class nsIRemoteOpenFileListener; |
michael@0 | 21 | template<class E, uint32_t N> class nsAutoTArray; |
michael@0 | 22 | |
michael@0 | 23 | class nsJARProtocolHandler : public nsIJARProtocolHandler |
michael@0 | 24 | , public nsSupportsWeakReference |
michael@0 | 25 | { |
michael@0 | 26 | typedef nsAutoTArray<nsCOMPtr<nsIRemoteOpenFileListener>, 5> |
michael@0 | 27 | RemoteFileListenerArray; |
michael@0 | 28 | |
michael@0 | 29 | public: |
michael@0 | 30 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 31 | NS_DECL_NSIPROTOCOLHANDLER |
michael@0 | 32 | NS_DECL_NSIJARPROTOCOLHANDLER |
michael@0 | 33 | |
michael@0 | 34 | // nsJARProtocolHandler methods: |
michael@0 | 35 | nsJARProtocolHandler(); |
michael@0 | 36 | virtual ~nsJARProtocolHandler(); |
michael@0 | 37 | |
michael@0 | 38 | static nsJARProtocolHandler *GetSingleton(); |
michael@0 | 39 | |
michael@0 | 40 | nsresult Init(); |
michael@0 | 41 | |
michael@0 | 42 | // returns non addref'ed pointer. |
michael@0 | 43 | nsIMIMEService *MimeService(); |
michael@0 | 44 | nsIZipReaderCache *JarCache() { return mJARCache; } |
michael@0 | 45 | |
michael@0 | 46 | bool IsMainProcess() const { return mIsMainProcess; } |
michael@0 | 47 | |
michael@0 | 48 | bool RemoteOpenFileInProgress(nsIHashable *aRemoteFile, |
michael@0 | 49 | nsIRemoteOpenFileListener *aListener); |
michael@0 | 50 | void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | nsCOMPtr<nsIZipReaderCache> mJARCache; |
michael@0 | 54 | nsCOMPtr<nsIMIMEService> mMimeService; |
michael@0 | 55 | |
michael@0 | 56 | // Holds lists of RemoteOpenFileChild (not including the 1st) that have |
michael@0 | 57 | // requested the same file from parent. |
michael@0 | 58 | nsClassHashtable<nsHashableHashKey, RemoteFileListenerArray> |
michael@0 | 59 | mRemoteFileListeners; |
michael@0 | 60 | |
michael@0 | 61 | bool mIsMainProcess; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | extern nsJARProtocolHandler *gJarHandler; |
michael@0 | 65 | |
michael@0 | 66 | #define NS_JARPROTOCOLHANDLER_CID \ |
michael@0 | 67 | { /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */ \ |
michael@0 | 68 | 0xc7e410d4, \ |
michael@0 | 69 | 0x85f2, \ |
michael@0 | 70 | 0x11d3, \ |
michael@0 | 71 | {0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \ |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | #endif // !nsJARProtocolHandler_h__ |