Backed out changeset c40e797b011f (bug 765285) for ASAN bustage. r=whyunsetc-nanyway
[gecko.git] / modules / libjar / nsJARProtocolHandler.h
blob5895ad10f520f9437216fccc12fb917a352fbecb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsJARProtocolHandler_h__
7 #define nsJARProtocolHandler_h__
9 #include "nsIJARProtocolHandler.h"
10 #include "nsIProtocolHandler.h"
11 #include "nsIJARURI.h"
12 #include "nsIZipReader.h"
13 #include "nsIMIMEService.h"
14 #include "nsWeakReference.h"
15 #include "nsCOMPtr.h"
16 #include "nsClassHashtable.h"
17 #include "nsHashKeys.h"
19 class nsIHashable;
20 class nsIRemoteOpenFileListener;
21 template<class E, uint32_t N> class nsAutoTArray;
23 class nsJARProtocolHandler : public nsIJARProtocolHandler
24 , public nsSupportsWeakReference
26 typedef nsAutoTArray<nsCOMPtr<nsIRemoteOpenFileListener>, 5>
27 RemoteFileListenerArray;
29 public:
30 NS_DECL_THREADSAFE_ISUPPORTS
31 NS_DECL_NSIPROTOCOLHANDLER
32 NS_DECL_NSIJARPROTOCOLHANDLER
34 // nsJARProtocolHandler methods:
35 nsJARProtocolHandler();
36 virtual ~nsJARProtocolHandler();
38 static nsJARProtocolHandler *GetSingleton();
40 nsresult Init();
42 // returns non addref'ed pointer.
43 nsIMIMEService *MimeService();
44 nsIZipReaderCache *JarCache() { return mJARCache; }
46 bool IsMainProcess() const { return mIsMainProcess; }
48 bool RemoteOpenFileInProgress(nsIHashable *aRemoteFile,
49 nsIRemoteOpenFileListener *aListener);
50 void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus);
52 protected:
53 nsCOMPtr<nsIZipReaderCache> mJARCache;
54 nsCOMPtr<nsIMIMEService> mMimeService;
56 // Holds lists of RemoteOpenFileChild (not including the 1st) that have
57 // requested the same file from parent.
58 nsClassHashtable<nsHashableHashKey, RemoteFileListenerArray>
59 mRemoteFileListeners;
61 bool mIsMainProcess;
64 extern nsJARProtocolHandler *gJarHandler;
66 #define NS_JARPROTOCOLHANDLER_CID \
67 { /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */ \
68 0xc7e410d4, \
69 0x85f2, \
70 0x11d3, \
71 {0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
74 #endif // !nsJARProtocolHandler_h__