Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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