| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // |
| 11 // SdchFilter is also a subclass of Filter. See the latter's header file | 11 // SdchFilter is also a subclass of Filter. See the latter's header file |
| 12 // filter.h for sample usage. | 12 // filter.h for sample usage. |
| 13 | 13 |
| 14 #ifndef NET_FILTER_SDCH_FILTER_H_ | 14 #ifndef NET_FILTER_SDCH_FILTER_H_ |
| 15 #define NET_FILTER_SDCH_FILTER_H_ | 15 #define NET_FILTER_SDCH_FILTER_H_ |
| 16 | 16 |
| 17 #include <stddef.h> | 17 #include <stddef.h> |
| 18 | 18 |
| 19 #include <memory> |
| 19 #include <string> | 20 #include <string> |
| 20 | 21 |
| 21 #include "base/macros.h" | 22 #include "base/macros.h" |
| 22 #include "base/memory/scoped_ptr.h" | |
| 23 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
| 24 #include "net/base/sdch_dictionary.h" | 24 #include "net/base/sdch_dictionary.h" |
| 25 #include "net/base/sdch_manager.h" | 25 #include "net/base/sdch_manager.h" |
| 26 #include "net/filter/filter.h" | 26 #include "net/filter/filter.h" |
| 27 | 27 |
| 28 namespace open_vcdiff { | 28 namespace open_vcdiff { |
| 29 class VCDiffStreamingDecoder; | 29 class VCDiffStreamingDecoder; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace net { | 32 namespace net { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const FilterContext& filter_context_; | 75 const FilterContext& filter_context_; |
| 76 | 76 |
| 77 // Tracks the status of decoding. | 77 // Tracks the status of decoding. |
| 78 // This variable is initialized by InitDecoding and updated only by | 78 // This variable is initialized by InitDecoding and updated only by |
| 79 // ReadFilteredData. | 79 // ReadFilteredData. |
| 80 DecodingStatus decoding_status_; | 80 DecodingStatus decoding_status_; |
| 81 | 81 |
| 82 // The underlying decoder that processes data. | 82 // The underlying decoder that processes data. |
| 83 // This data structure is initialized by InitDecoding and updated in | 83 // This data structure is initialized by InitDecoding and updated in |
| 84 // ReadFilteredData. | 84 // ReadFilteredData. |
| 85 scoped_ptr<open_vcdiff::VCDiffStreamingDecoder> vcdiff_streaming_decoder_; | 85 std::unique_ptr<open_vcdiff::VCDiffStreamingDecoder> |
| 86 vcdiff_streaming_decoder_; |
| 86 | 87 |
| 87 // After the encoded response SDCH header is read, this variable contains | 88 // After the encoded response SDCH header is read, this variable contains |
| 88 // the server hash with trailing null byte. | 89 // the server hash with trailing null byte. |
| 89 std::string dictionary_hash_; | 90 std::string dictionary_hash_; |
| 90 | 91 |
| 91 // After assembling an entire dictionary hash (the first 9 bytes of the | 92 // After assembling an entire dictionary hash (the first 9 bytes of the |
| 92 // sdch payload, we check to see if it is plausible, meaning it has a null | 93 // sdch payload, we check to see if it is plausible, meaning it has a null |
| 93 // termination, and has 8 characters that are possible in a net-safe base64 | 94 // termination, and has 8 characters that are possible in a net-safe base64 |
| 94 // encoding. If the hash is not plausible, then the payload is probably not | 95 // encoding. If the hash is not plausible, then the payload is probably not |
| 95 // an SDCH encoded bundle, and various error recovery strategies can be | 96 // an SDCH encoded bundle, and various error recovery strategies can be |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 // This is used to restrict use of a dictionary to a specific URL or path. | 125 // This is used to restrict use of a dictionary to a specific URL or path. |
| 125 GURL url_; | 126 GURL url_; |
| 126 | 127 |
| 127 // To facilitate error recovery, allow filter to know if content is text/html | 128 // To facilitate error recovery, allow filter to know if content is text/html |
| 128 // by checking within this mime type (we may do a meta-refresh via html). | 129 // by checking within this mime type (we may do a meta-refresh via html). |
| 129 std::string mime_type_; | 130 std::string mime_type_; |
| 130 | 131 |
| 131 // If the response was encoded with a dictionary different than those | 132 // If the response was encoded with a dictionary different than those |
| 132 // advertised (e.g. a cached response using an old dictionary), this | 133 // advertised (e.g. a cached response using an old dictionary), this |
| 133 // variable preserves that dictionary from deletion during decoding. | 134 // variable preserves that dictionary from deletion during decoding. |
| 134 scoped_ptr<SdchManager::DictionarySet> unexpected_dictionary_handle_; | 135 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_handle_; |
| 135 | 136 |
| 136 DISALLOW_COPY_AND_ASSIGN(SdchFilter); | 137 DISALLOW_COPY_AND_ASSIGN(SdchFilter); |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 } // namespace net | 140 } // namespace net |
| 140 | 141 |
| 141 #endif // NET_FILTER_SDCH_FILTER_H_ | 142 #endif // NET_FILTER_SDCH_FILTER_H_ |
| OLD | NEW |