modules/libjar/nsJARProtocolHandler.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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
    25 {
    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;
    62 };
    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} \
    72 }
    74 #endif // !nsJARProtocolHandler_h__

mercurial