|
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/. */ |
|
5 |
|
6 #ifndef nsJARProtocolHandler_h__ |
|
7 #define nsJARProtocolHandler_h__ |
|
8 |
|
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" |
|
18 |
|
19 class nsIHashable; |
|
20 class nsIRemoteOpenFileListener; |
|
21 template<class E, uint32_t N> class nsAutoTArray; |
|
22 |
|
23 class nsJARProtocolHandler : public nsIJARProtocolHandler |
|
24 , public nsSupportsWeakReference |
|
25 { |
|
26 typedef nsAutoTArray<nsCOMPtr<nsIRemoteOpenFileListener>, 5> |
|
27 RemoteFileListenerArray; |
|
28 |
|
29 public: |
|
30 NS_DECL_THREADSAFE_ISUPPORTS |
|
31 NS_DECL_NSIPROTOCOLHANDLER |
|
32 NS_DECL_NSIJARPROTOCOLHANDLER |
|
33 |
|
34 // nsJARProtocolHandler methods: |
|
35 nsJARProtocolHandler(); |
|
36 virtual ~nsJARProtocolHandler(); |
|
37 |
|
38 static nsJARProtocolHandler *GetSingleton(); |
|
39 |
|
40 nsresult Init(); |
|
41 |
|
42 // returns non addref'ed pointer. |
|
43 nsIMIMEService *MimeService(); |
|
44 nsIZipReaderCache *JarCache() { return mJARCache; } |
|
45 |
|
46 bool IsMainProcess() const { return mIsMainProcess; } |
|
47 |
|
48 bool RemoteOpenFileInProgress(nsIHashable *aRemoteFile, |
|
49 nsIRemoteOpenFileListener *aListener); |
|
50 void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus); |
|
51 |
|
52 protected: |
|
53 nsCOMPtr<nsIZipReaderCache> mJARCache; |
|
54 nsCOMPtr<nsIMIMEService> mMimeService; |
|
55 |
|
56 // Holds lists of RemoteOpenFileChild (not including the 1st) that have |
|
57 // requested the same file from parent. |
|
58 nsClassHashtable<nsHashableHashKey, RemoteFileListenerArray> |
|
59 mRemoteFileListeners; |
|
60 |
|
61 bool mIsMainProcess; |
|
62 }; |
|
63 |
|
64 extern nsJARProtocolHandler *gJarHandler; |
|
65 |
|
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} \ |
|
72 } |
|
73 |
|
74 #endif // !nsJARProtocolHandler_h__ |