modules/libjar/zipwriter/src/nsDeflateConverter.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial