| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BIN_FILTER_H_ | 5 #ifndef BIN_FILTER_H_ |
| 6 #define BIN_FILTER_H_ | 6 #define BIN_FILTER_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 private: | 47 private: |
| 48 static const intptr_t kFilterBufferSize = 64 * KB; | 48 static const intptr_t kFilterBufferSize = 64 * KB; |
| 49 uint8_t processed_buffer_[kFilterBufferSize]; | 49 uint8_t processed_buffer_[kFilterBufferSize]; |
| 50 bool initialized_; | 50 bool initialized_; |
| 51 | 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(Filter); | 52 DISALLOW_COPY_AND_ASSIGN(Filter); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class ZLibDeflateFilter : public Filter { | 55 class ZLibDeflateFilter : public Filter { |
| 56 public: | 56 public: |
| 57 ZLibDeflateFilter(bool gzip = false, int level = 6) | 57 ZLibDeflateFilter(bool gzip = false, int level = 6, int windowBits = 15, |
| 58 : gzip_(gzip), level_(level), current_buffer_(NULL) {} | 58 bool raw = false) : |
| 59 gzip_(gzip), level_(level), windowBits_(windowBits), raw_(raw), |
| 60 current_buffer_(NULL) |
| 61 {} |
| 59 virtual ~ZLibDeflateFilter(); | 62 virtual ~ZLibDeflateFilter(); |
| 60 | 63 |
| 61 virtual bool Init(); | 64 virtual bool Init(); |
| 62 virtual bool Process(uint8_t* data, intptr_t length); | 65 virtual bool Process(uint8_t* data, intptr_t length); |
| 63 virtual intptr_t Processed(uint8_t* buffer, | 66 virtual intptr_t Processed(uint8_t* buffer, |
| 64 intptr_t length, | 67 intptr_t length, |
| 65 bool finish, | 68 bool finish, |
| 66 bool end); | 69 bool end); |
| 67 | 70 |
| 68 private: | 71 private: |
| 69 const bool gzip_; | 72 const bool gzip_; |
| 70 const int level_; | 73 const int level_; |
| 74 const int windowBits_; |
| 75 const bool raw_; |
| 71 uint8_t* current_buffer_; | 76 uint8_t* current_buffer_; |
| 72 z_stream stream_; | 77 z_stream stream_; |
| 73 | 78 |
| 74 DISALLOW_COPY_AND_ASSIGN(ZLibDeflateFilter); | 79 DISALLOW_COPY_AND_ASSIGN(ZLibDeflateFilter); |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 class ZLibInflateFilter : public Filter { | 82 class ZLibInflateFilter : public Filter { |
| 78 public: | 83 public: |
| 79 ZLibInflateFilter() : current_buffer_(NULL) {} | 84 ZLibInflateFilter(int windowBits = 15, bool raw = false) : |
| 85 windowBits_(windowBits), raw_(raw), current_buffer_(NULL) |
| 86 {} |
| 80 virtual ~ZLibInflateFilter(); | 87 virtual ~ZLibInflateFilter(); |
| 81 | 88 |
| 82 virtual bool Init(); | 89 virtual bool Init(); |
| 83 virtual bool Process(uint8_t* data, intptr_t length); | 90 virtual bool Process(uint8_t* data, intptr_t length); |
| 84 virtual intptr_t Processed(uint8_t* buffer, | 91 virtual intptr_t Processed(uint8_t* buffer, |
| 85 intptr_t length, | 92 intptr_t length, |
| 86 bool finish, | 93 bool finish, |
| 87 bool end); | 94 bool end); |
| 88 | 95 |
| 89 private: | 96 private: |
| 97 const int windowBits_; |
| 98 const bool raw_; |
| 90 uint8_t* current_buffer_; | 99 uint8_t* current_buffer_; |
| 91 z_stream stream_; | 100 z_stream stream_; |
| 92 | 101 |
| 93 DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter); | 102 DISALLOW_COPY_AND_ASSIGN(ZLibInflateFilter); |
| 94 }; | 103 }; |
| 95 | 104 |
| 96 } // namespace bin | 105 } // namespace bin |
| 97 } // namespace dart | 106 } // namespace dart |
| 98 | 107 |
| 99 #endif // BIN_FILTER_H_ | 108 #endif // BIN_FILTER_H_ |
| OLD | NEW |