Chromium Code Reviews| Index: net/filter/brotli_filter.h |
| diff --git a/net/filter/brotli_filter.h b/net/filter/brotli_filter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2ae3a21a4aca4e9204677f6007fd1d3d50d0d655 |
| --- /dev/null |
| +++ b/net/filter/brotli_filter.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// BrotliFilter applies Brotli content decoding to a data |
| +// stream. |
|
cbentzel
2015/11/14 01:20:10
Can you include a reference to Brotli here?
eustas
2015/11/16 14:26:23
Done.
|
| +// |
| +// BrotliFilter is a subclass of Filter. See the latter's header file filter.h |
| +// for sample usage. |
| + |
| +#ifndef NET_FILTER_BROTLI_FILTER_H_ |
| +#define NET_FILTER_BROTLI_FILTER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "net/filter/filter.h" |
| + |
| +struct BrotliStateStruct; |
| + |
| +namespace net { |
| + |
| +class BrotliFilter : public Filter { |
| + public: |
| + ~BrotliFilter() override; |
| + |
| + // Initializes filter decoding mode and internal control blocks. |
| + // The function returns true if success and false otherwise. |
| + // The filter can only be initialized once. |
| + bool InitDecoding(); |
| + |
| + // Decodes the pre-filter data and writes the output into the dest_buffer |
| + // passed in. |
| + // The function returns FilterStatus. See filter.h for its description. |
| + // |
| + // Upon entry, *dest_len is the total size (in number of chars) of the |
| + // destination buffer. Upon exit, *dest_len is the actual number of chars |
| + // written into the destination buffer. |
| + // |
| + // This function will fail if there is no pre-filter data in the |
| + // stream_buffer_. On the other hand, *dest_len can be 0 upon successful |
| + // return. For example, decompressor may process some pre-filter data |
| + // but not produce output yet. |
| + FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len) override; |
| + |
| + private: |
| + enum DecodingStatus { |
| + DECODING_UNINITIALIZED, |
| + DECODING_IN_PROGRESS, |
| + DECODING_DONE, |
| + DECODING_ERROR |
| + }; |
| + |
| + // Only to be instantiated by Filter::Factory. |
| + BrotliFilter(FilterType type); |
| + friend class Filter; |
| + |
| + bool CheckBrotliHeader(); |
| + |
| + // Tracks the status of decoding. |
| + // This variable is initialized by InitDecoding and updated only by |
| + // ReadFilteredData. |
| + DecodingStatus decoding_status_; |
| + |
| + scoped_ptr<BrotliStateStruct> brotli_state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BrotliFilter); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_FILTER_BROTLI_FILTER_H__ |