| 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 // 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Internal status. Once we enter an error state, we stop processing data. | 49 // Internal status. Once we enter an error state, we stop processing data. |
| 50 enum DecodingStatus { | 50 enum DecodingStatus { |
| 51 DECODING_UNINITIALIZED, | 51 DECODING_UNINITIALIZED, |
| 52 WAITING_FOR_DICTIONARY_SELECTION, | 52 WAITING_FOR_DICTIONARY_SELECTION, |
| 53 DECODING_IN_PROGRESS, | 53 DECODING_IN_PROGRESS, |
| 54 DECODING_ERROR, | 54 DECODING_ERROR, |
| 55 META_REFRESH_RECOVERY, // Decoding error being handled by a meta-refresh. | 55 META_REFRESH_RECOVERY, // Decoding error being handled by a meta-refresh. |
| 56 PASS_THROUGH, // Non-sdch content being passed without alteration. | 56 PASS_THROUGH, // Non-sdch content being passed without alteration. |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Update the read_times_ array with time estimates for the number of packets | |
| 60 // read so far. | |
| 61 void UpdateReadTimes(); | |
| 62 | |
| 63 // Identify the suggested dictionary, and initialize underlying decompressor. | 59 // Identify the suggested dictionary, and initialize underlying decompressor. |
| 64 Filter::FilterStatus InitializeDictionary(); | 60 Filter::FilterStatus InitializeDictionary(); |
| 65 | 61 |
| 66 // Move data that was internally buffered (after decompression) to the | 62 // Move data that was internally buffered (after decompression) to the |
| 67 // specified dest_buffer. | 63 // specified dest_buffer. |
| 68 int OutputBufferExcess(char* const dest_buffer, size_t available_space); | 64 int OutputBufferExcess(char* const dest_buffer, size_t available_space); |
| 69 | 65 |
| 70 // Tracks the status of decoding. | 66 // Tracks the status of decoding. |
| 71 // This variable is initialized by InitDecoding and updated only by | 67 // This variable is initialized by InitDecoding and updated only by |
| 72 // ReadFilteredData. | 68 // ReadFilteredData. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 99 std::string dest_buffer_excess_; | 95 std::string dest_buffer_excess_; |
| 100 // To avoid moving strings around too much, we save the index into | 96 // To avoid moving strings around too much, we save the index into |
| 101 // dest_buffer_excess_ that has the next byte to output. | 97 // dest_buffer_excess_ that has the next byte to output. |
| 102 size_t dest_buffer_excess_index_; | 98 size_t dest_buffer_excess_index_; |
| 103 | 99 |
| 104 // To get stats on activities, we keep track of source and target bytes. | 100 // To get stats on activities, we keep track of source and target bytes. |
| 105 // Visit about:histograms/Sdch to see histogram data. | 101 // Visit about:histograms/Sdch to see histogram data. |
| 106 size_t source_bytes_; | 102 size_t source_bytes_; |
| 107 size_t output_bytes_; | 103 size_t output_bytes_; |
| 108 | 104 |
| 109 // The number of packets we've observed over the net. | |
| 110 size_t observed_packet_count_; | |
| 111 | |
| 112 // We can't really see when a packet arrives, but we can record how much data | |
| 113 // was accounted for in previously noted packets. We use this count to (later) | |
| 114 // identify new packets . | |
| 115 size_t bytes_observed_in_packets_; | |
| 116 | |
| 117 // Since we don't save all packet times in read_times_, we save the last time | |
| 118 // for use in histograms. | |
| 119 base::Time final_packet_time_; | |
| 120 | |
| 121 // Record of packet processing times for this filter. Used only for stats | |
| 122 // generations in histograms. There is one time entry each time the byte | |
| 123 // count receieved exceeds the next multiple of 1430 bytes (a common | |
| 124 // per-TCP/IP-packet payload size). It is currently only valid for the first | |
| 125 // 5 packets. | |
| 126 std::vector<base::Time> read_times_; | |
| 127 | |
| 128 // Error recovery in content type may add an sdch filter type, in which case | 105 // Error recovery in content type may add an sdch filter type, in which case |
| 129 // we should gracefully perform pass through if the format is incorrect, or | 106 // we should gracefully perform pass through if the format is incorrect, or |
| 130 // an applicable dictionary can't be found. | 107 // an applicable dictionary can't be found. |
| 131 bool possible_pass_through_; | 108 bool possible_pass_through_; |
| 132 | 109 |
| 133 // The URL that is currently being filtered. | 110 // The URL that is currently being filtered. |
| 134 // This is used to restrict use of a dictionary to a specific URL or path. | 111 // This is used to restrict use of a dictionary to a specific URL or path. |
| 135 GURL url_; | 112 GURL url_; |
| 136 | 113 |
| 137 // To facilitate histogramming by individual filters, we store the connect | 114 // To facilitate error recovery, we store whether this content came from a |
| 138 // time for the corresponding HTTP transaction, as well as whether this time | 115 // cache, as we then probably don't have the requsite dictionary, and will |
| 139 // was recalled from a cached entry. The time is approximate, and may be | 116 // need to induce a meta-refresh. |
| 140 // bogus if the data was gotten from cache (i.e., it may be LOOOONG ago). | |
| 141 const base::Time connect_time_; | |
| 142 const bool was_cached_; | 117 const bool was_cached_; |
| 143 | 118 |
| 144 // To facilitate error recovery, allow filter to know if content is text/html | 119 // To facilitate error recovery, allow filter to know if content is text/html |
| 145 // by checking within this mime type (we may do a meta-refresh via html). | 120 // by checking within this mime type (we may do a meta-refresh via html). |
| 146 std::string mime_type_; | 121 std::string mime_type_; |
| 147 | 122 |
| 148 DISALLOW_COPY_AND_ASSIGN(SdchFilter); | 123 DISALLOW_COPY_AND_ASSIGN(SdchFilter); |
| 149 }; | 124 }; |
| 150 | 125 |
| 151 #endif // NET_BASE_SDCH_FILTER_H_ | 126 #endif // NET_BASE_SDCH_FILTER_H_ |
| OLD | NEW |