modules/libjar/nsJARProtocolHandler.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/nsJARProtocolHandler.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsJARProtocolHandler_h__
    1.10 +#define nsJARProtocolHandler_h__
    1.11 +
    1.12 +#include "nsIJARProtocolHandler.h"
    1.13 +#include "nsIProtocolHandler.h"
    1.14 +#include "nsIJARURI.h"
    1.15 +#include "nsIZipReader.h"
    1.16 +#include "nsIMIMEService.h"
    1.17 +#include "nsWeakReference.h"
    1.18 +#include "nsCOMPtr.h"
    1.19 +#include "nsClassHashtable.h"
    1.20 +#include "nsHashKeys.h"
    1.21 +
    1.22 +class nsIHashable;
    1.23 +class nsIRemoteOpenFileListener;
    1.24 +template<class E, uint32_t N> class nsAutoTArray;
    1.25 +
    1.26 +class nsJARProtocolHandler : public nsIJARProtocolHandler
    1.27 +                           , public nsSupportsWeakReference
    1.28 +{
    1.29 +    typedef nsAutoTArray<nsCOMPtr<nsIRemoteOpenFileListener>, 5>
    1.30 +            RemoteFileListenerArray;
    1.31 +
    1.32 +public:
    1.33 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.34 +    NS_DECL_NSIPROTOCOLHANDLER
    1.35 +    NS_DECL_NSIJARPROTOCOLHANDLER
    1.36 +
    1.37 +    // nsJARProtocolHandler methods:
    1.38 +    nsJARProtocolHandler();
    1.39 +    virtual ~nsJARProtocolHandler();
    1.40 +
    1.41 +    static nsJARProtocolHandler *GetSingleton();
    1.42 +
    1.43 +    nsresult Init();
    1.44 +
    1.45 +    // returns non addref'ed pointer.  
    1.46 +    nsIMIMEService    *MimeService();
    1.47 +    nsIZipReaderCache *JarCache() { return mJARCache; }
    1.48 +
    1.49 +    bool IsMainProcess() const { return mIsMainProcess; }
    1.50 +
    1.51 +    bool RemoteOpenFileInProgress(nsIHashable *aRemoteFile,
    1.52 +                                  nsIRemoteOpenFileListener *aListener);
    1.53 +    void RemoteOpenFileComplete(nsIHashable *aRemoteFile, nsresult aStatus);
    1.54 +
    1.55 +protected:
    1.56 +    nsCOMPtr<nsIZipReaderCache> mJARCache;
    1.57 +    nsCOMPtr<nsIMIMEService> mMimeService;
    1.58 +
    1.59 +    // Holds lists of RemoteOpenFileChild (not including the 1st) that have
    1.60 +    // requested the same file from parent.
    1.61 +    nsClassHashtable<nsHashableHashKey, RemoteFileListenerArray>
    1.62 +        mRemoteFileListeners;
    1.63 +
    1.64 +    bool mIsMainProcess;
    1.65 +};
    1.66 +
    1.67 +extern nsJARProtocolHandler *gJarHandler;
    1.68 +
    1.69 +#define NS_JARPROTOCOLHANDLER_CID                    \
    1.70 +{ /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */     \
    1.71 +    0xc7e410d4,                                      \
    1.72 +    0x85f2,                                          \
    1.73 +    0x11d3,                                          \
    1.74 +    {0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
    1.75 +}
    1.76 +
    1.77 +#endif // !nsJARProtocolHandler_h__

mercurial