| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // BZip2Filter applies bzip2 content encoding/decoding to a datastream. | 5 // BZip2Filter applies bzip2 content encoding/decoding to a datastream. |
| 6 // Since it is a new feature, and no specification said what 's bzip2 content | 6 // Since it is a new feature, and no specification said what 's bzip2 content |
| 7 // composed of in http protocol. So I assume with bzip2 encoding the content | 7 // composed of in http protocol. So I assume with bzip2 encoding the content |
| 8 // is full format, which means the content should carry complete bzip2 head, | 8 // is full format, which means the content should carry complete bzip2 head, |
| 9 // such as inlcude magic number 1(BZh), block size bit, magic number 2(0x31, | 9 // such as inlcude magic number 1(BZh), block size bit, magic number 2(0x31, |
| 10 // 0x41, 0x59, 0x26, 0xx53, 0x59) | 10 // 0x41, 0x59, 0x26, 0xx53, 0x59) |
| 11 // Maybe need to inserts a bzlib2 header to the data stream before calling | 11 // Maybe need to inserts a bzlib2 header to the data stream before calling |
| 12 // decompression functionality, but at now I do not meet this sort of real | 12 // decompression functionality, but at now I do not meet this sort of real |
| 13 // scenarios. So let's see the further requests. | 13 // scenarios. So let's see the further requests. |
| 14 // | 14 // |
| 15 // This BZip2Filter internally uses third_party/bzip2 library to do decoding. | 15 // This BZip2Filter internally uses third_party/bzip2 library to do decoding. |
| 16 // | 16 // |
| 17 // BZip2Filter is also a subclass of Filter. See the latter's header file | 17 // BZip2Filter is also a subclass of Filter. See the latter's header file |
| 18 // filter.h for sample usage. | 18 // filter.h for sample usage. |
| 19 | 19 |
| 20 #ifndef NET_BASE_BZIP2_FILTER_H_ | 20 #ifndef NET_BASE_BZIP2_FILTER_H_ |
| 21 #define NET_BASE_BZIP2_FILTER_H_ | 21 #define NET_BASE_BZIP2_FILTER_H_ |
| 22 | 22 |
| 23 #if defined(USE_SYSTEM_LIBBZ2) |
| 24 #include <bzlib.h> |
| 25 #else |
| 26 #include "third_party/bzip2/bzlib.h" |
| 27 #endif |
| 28 |
| 23 #include "base/scoped_ptr.h" | 29 #include "base/scoped_ptr.h" |
| 24 #include "net/base/filter.h" | 30 #include "net/base/filter.h" |
| 25 #include "third_party/bzip2/bzlib.h" | |
| 26 | 31 |
| 27 class BZip2Filter : public Filter { | 32 class BZip2Filter : public Filter { |
| 28 public: | 33 public: |
| 29 explicit BZip2Filter(const FilterContext& filter_context); | 34 explicit BZip2Filter(const FilterContext& filter_context); |
| 30 | 35 |
| 31 virtual ~BZip2Filter(); | 36 virtual ~BZip2Filter(); |
| 32 | 37 |
| 33 // Initializes filter decoding mode and internal control blocks. | 38 // Initializes filter decoding mode and internal control blocks. |
| 34 // Parameter use_small_memory specifies whether use small memory | 39 // Parameter use_small_memory specifies whether use small memory |
| 35 // to decompresss data. If small is nonzero, the bzip2 library will | 40 // to decompresss data. If small is nonzero, the bzip2 library will |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 79 |
| 75 // The control block of bzip which actually does the decoding. | 80 // The control block of bzip which actually does the decoding. |
| 76 // This data structure is initialized by InitDecoding and updated in | 81 // This data structure is initialized by InitDecoding and updated in |
| 77 // ReadFilteredData. | 82 // ReadFilteredData. |
| 78 scoped_ptr<bz_stream> bzip2_data_stream_; | 83 scoped_ptr<bz_stream> bzip2_data_stream_; |
| 79 | 84 |
| 80 DISALLOW_COPY_AND_ASSIGN(BZip2Filter); | 85 DISALLOW_COPY_AND_ASSIGN(BZip2Filter); |
| 81 }; | 86 }; |
| 82 | 87 |
| 83 #endif // NET_BASE_BZIP2_FILTER_H_ | 88 #endif // NET_BASE_BZIP2_FILTER_H_ |
| OLD | NEW |