modules/libjar/zipwriter/src/nsDeflateConverter.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 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     4  */
     6 #ifndef _nsDeflateConverter_h_
     7 #define _nsDeflateConverter_h_
     9 #include "nsIStreamConverter.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsIPipe.h"
    12 #include "zlib.h"
    13 #include "mozilla/Attributes.h"
    15 #define DEFLATECONVERTER_CID { 0x461cd5dd, 0x73c6, 0x47a4, \
    16            { 0x8c, 0xc3, 0x60, 0x3b, 0x37, 0xd8, 0x4a, 0x61 } }
    18 #define ZIP_BUFLEN (4 * 1024 - 1)
    20 class nsDeflateConverter MOZ_FINAL : public nsIStreamConverter
    21 {
    22 public:
    23     NS_DECL_ISUPPORTS
    24     NS_DECL_NSIREQUESTOBSERVER
    25     NS_DECL_NSISTREAMLISTENER
    26     NS_DECL_NSISTREAMCONVERTER
    28     nsDeflateConverter()
    29     {
    30         // 6 is Z_DEFAULT_COMPRESSION but we need the actual value
    31         mLevel = 6;
    32     }
    34     nsDeflateConverter(int32_t level)
    35     {
    36         mLevel = level;
    37     }
    39 private:
    41     ~nsDeflateConverter()
    42     {
    43     }
    45     enum WrapMode {
    46         WRAP_ZLIB,
    47         WRAP_GZIP,
    48         WRAP_NONE
    49     };
    51     WrapMode mWrapMode;
    52     uint64_t mOffset;
    53     int32_t mLevel;
    54     nsCOMPtr<nsIStreamListener> mListener;
    55     nsCOMPtr<nsISupports> mContext;
    56     z_stream mZstream;
    57     unsigned char mWriteBuffer[ZIP_BUFLEN];
    59     nsresult Init();
    60     nsresult PushAvailableData(nsIRequest *aRequest, nsISupports *aContext);
    61 };
    63 #endif

mercurial