modules/libjar/zipwriter/src/nsDeflateConverter.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:347e7d50f498
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 */
5
6 #ifndef _nsDeflateConverter_h_
7 #define _nsDeflateConverter_h_
8
9 #include "nsIStreamConverter.h"
10 #include "nsCOMPtr.h"
11 #include "nsIPipe.h"
12 #include "zlib.h"
13 #include "mozilla/Attributes.h"
14
15 #define DEFLATECONVERTER_CID { 0x461cd5dd, 0x73c6, 0x47a4, \
16 { 0x8c, 0xc3, 0x60, 0x3b, 0x37, 0xd8, 0x4a, 0x61 } }
17
18 #define ZIP_BUFLEN (4 * 1024 - 1)
19
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
27
28 nsDeflateConverter()
29 {
30 // 6 is Z_DEFAULT_COMPRESSION but we need the actual value
31 mLevel = 6;
32 }
33
34 nsDeflateConverter(int32_t level)
35 {
36 mLevel = level;
37 }
38
39 private:
40
41 ~nsDeflateConverter()
42 {
43 }
44
45 enum WrapMode {
46 WRAP_ZLIB,
47 WRAP_GZIP,
48 WRAP_NONE
49 };
50
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];
58
59 nsresult Init();
60 nsresult PushAvailableData(nsIRequest *aRequest, nsISupports *aContext);
61 };
62
63 #endif

mercurial