Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // SdchFilter applies open_vcdiff content decoding to a datastream. | 5 // SdchFilter applies open_vcdiff content decoding to a datastream. |
| 6 // This decoding uses a pre-cached dictionary of text fragments to decode | 6 // This decoding uses a pre-cached dictionary of text fragments to decode |
| 7 // (expand) the stream back to its original contents. | 7 // (expand) the stream back to its original contents. |
| 8 // | 8 // |
| 9 // This SdchFilter internally uses open_vcdiff/vcdec library to do decoding. | 9 // This SdchFilter internally uses open_vcdiff/vcdec library to do decoding. |
| 10 // | 10 // |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "net/base/sdch_manager.h" | 22 #include "net/base/sdch_manager.h" |
| 23 | 23 |
| 24 namespace open_vcdiff { | 24 namespace open_vcdiff { |
| 25 class VCDiffStreamingDecoder; | 25 class VCDiffStreamingDecoder; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 | 29 |
| 30 class SdchFilter : public Filter { | 30 class SdchFilter : public Filter { |
| 31 public: | 31 public: |
| 32 explicit SdchFilter(const FilterContext& filter_context); | |
| 33 | |
| 34 virtual ~SdchFilter(); | 32 virtual ~SdchFilter(); |
| 35 | 33 |
| 36 // Initializes filter decoding mode and internal control blocks. | 34 // Initializes filter decoding mode and internal control blocks. |
| 37 bool InitDecoding(Filter::FilterType filter_type); | 35 bool InitDecoding(Filter::FilterType filter_type); |
| 38 | 36 |
| 39 // Decode the pre-filter data and writes the output into |dest_buffer| | 37 // Decode the pre-filter data and writes the output into |dest_buffer| |
| 40 // The function returns FilterStatus. See filter.h for its description. | 38 // The function returns FilterStatus. See filter.h for its description. |
| 41 // | 39 // |
| 42 // Upon entry, *dest_len is the total size (in number of chars) of the | 40 // Upon entry, *dest_len is the total size (in number of chars) of the |
| 43 // destination buffer. Upon exit, *dest_len is the actual number of chars | 41 // destination buffer. Upon exit, *dest_len is the actual number of chars |
| 44 // written into the destination buffer. | 42 // written into the destination buffer. |
| 45 virtual FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len); | 43 virtual FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len); |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 // Internal status. Once we enter an error state, we stop processing data. | 46 // Internal status. Once we enter an error state, we stop processing data. |
| 49 enum DecodingStatus { | 47 enum DecodingStatus { |
| 50 DECODING_UNINITIALIZED, | 48 DECODING_UNINITIALIZED, |
| 51 WAITING_FOR_DICTIONARY_SELECTION, | 49 WAITING_FOR_DICTIONARY_SELECTION, |
| 52 DECODING_IN_PROGRESS, | 50 DECODING_IN_PROGRESS, |
| 53 DECODING_ERROR, | 51 DECODING_ERROR, |
| 54 META_REFRESH_RECOVERY, // Decoding error being handled by a meta-refresh. | 52 META_REFRESH_RECOVERY, // Decoding error being handled by a meta-refresh. |
| 55 PASS_THROUGH, // Non-sdch content being passed without alteration. | 53 PASS_THROUGH, // Non-sdch content being passed without alteration. |
| 56 }; | 54 }; |
| 57 | 55 |
| 56 // Only to be instantiated by Filter::Factory. | |
| 57 explicit SdchFilter(const FilterContext& filter_context); | |
|
jar (doing other things)
2011/03/01 22:44:03
The moving of these constructors to being private
| |
| 58 friend class Filter; | |
| 59 | |
| 58 // Identify the suggested dictionary, and initialize underlying decompressor. | 60 // Identify the suggested dictionary, and initialize underlying decompressor. |
| 59 Filter::FilterStatus InitializeDictionary(); | 61 Filter::FilterStatus InitializeDictionary(); |
| 60 | 62 |
| 61 // Move data that was internally buffered (after decompression) to the | 63 // Move data that was internally buffered (after decompression) to the |
| 62 // specified dest_buffer. | 64 // specified dest_buffer. |
| 63 int OutputBufferExcess(char* const dest_buffer, size_t available_space); | 65 int OutputBufferExcess(char* const dest_buffer, size_t available_space); |
| 64 | 66 |
| 65 // Tracks the status of decoding. | 67 // Tracks the status of decoding. |
| 66 // This variable is initialized by InitDecoding and updated only by | 68 // This variable is initialized by InitDecoding and updated only by |
| 67 // ReadFilteredData. | 69 // ReadFilteredData. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 // To facilitate error recovery, allow filter to know if content is text/html | 115 // To facilitate error recovery, allow filter to know if content is text/html |
| 114 // by checking within this mime type (we may do a meta-refresh via html). | 116 // by checking within this mime type (we may do a meta-refresh via html). |
| 115 std::string mime_type_; | 117 std::string mime_type_; |
| 116 | 118 |
| 117 DISALLOW_COPY_AND_ASSIGN(SdchFilter); | 119 DISALLOW_COPY_AND_ASSIGN(SdchFilter); |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 } // namespace net | 122 } // namespace net |
| 121 | 123 |
| 122 #endif // NET_BASE_SDCH_FILTER_H_ | 124 #endif // NET_BASE_SDCH_FILTER_H_ |
| OLD | NEW |