| 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 #include <ctype.h> | 5 #include <ctype.h> |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 if (vcdiff_streaming_decoder_.get()) { | 36 if (vcdiff_streaming_decoder_.get()) { |
| 37 if (!vcdiff_streaming_decoder_->FinishDecoding()) | 37 if (!vcdiff_streaming_decoder_->FinishDecoding()) |
| 38 decoding_status_ = DECODING_ERROR; | 38 decoding_status_ = DECODING_ERROR; |
| 39 } | 39 } |
| 40 | 40 |
| 41 if (base::Time() != connect_time() && base::Time() != time_of_last_read_) { | 41 if (base::Time() != connect_time() && base::Time() != time_of_last_read_) { |
| 42 base::TimeDelta duration = time_of_last_read_ - connect_time(); | 42 base::TimeDelta duration = time_of_last_read_ - connect_time(); |
| 43 // Note: connect_time may be somewhat incorrect if this is cached data, as | 43 // Note: connect_time may be somewhat incorrect if this is cached data, as |
| 44 // it will reflect the time the connect was done for the original read :-(. | 44 // it will reflect the time the connect was done for the original read :-(. |
| 45 // To avoid any chances of overflow (and since SDCH is meant to primarilly | 45 // To avoid any chances of overflow, and since SDCH is meant to primarilly |
| 46 // handle short downloads, we'll restrict what results we log to effectively | 46 // handle short downloads, we'll restrict what results we log to effectively |
| 47 // discard bogus large numbers. Note that IF the number is large enough, it | 47 // discard bogus large numbers. Note that IF the number is large enough, it |
| 48 // would DCHECK in histogram as the square of the value is summed. The | 48 // would DCHECK in histogram as the square of the value is summed. The |
| 49 // relatively precise histogram only properly covers the range 1ms to 10 | 49 // relatively precise histogram only properly covers the range 1ms to 10 |
| 50 // seconds, so the discarded data would not be that readable anyway. | 50 // seconds, so the discarded data would not be that readable anyway. |
| 51 if (30 >= duration.InSeconds()) { | 51 if (30 >= duration.InSeconds()) { |
| 52 if (DECODING_IN_PROGRESS == decoding_status_) | 52 if (DECODING_IN_PROGRESS == decoding_status_) |
| 53 UMA_HISTOGRAM_TIMES(L"Sdch.Transit_Latency", duration); | 53 UMA_HISTOGRAM_TIMES(L"Sdch.Transit_Latency_2", duration); |
| 54 if (PASS_THROUGH == decoding_status_) | 54 if (PASS_THROUGH == decoding_status_) |
| 55 UMA_HISTOGRAM_TIMES(L"Sdch.Transit_Pass-through_Latency", duration); | 55 UMA_HISTOGRAM_TIMES(L"Sdch.Transit_Pass-through_Latency_2", duration); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes read", source_bytes_); | 59 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes read", source_bytes_); |
| 60 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes output", output_bytes_); | 60 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes output", output_bytes_); |
| 61 | 61 |
| 62 if (dictionary_) | 62 if (dictionary_) |
| 63 dictionary_->Release(); | 63 dictionary_->Release(); |
| 64 } | 64 } |
| 65 | 65 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 83 | 83 |
| 84 | 84 |
| 85 Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, | 85 Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, |
| 86 int* dest_len) { | 86 int* dest_len) { |
| 87 int available_space = *dest_len; | 87 int available_space = *dest_len; |
| 88 *dest_len = 0; // Nothing output yet. | 88 *dest_len = 0; // Nothing output yet. |
| 89 | 89 |
| 90 if (!dest_buffer || available_space <= 0) | 90 if (!dest_buffer || available_space <= 0) |
| 91 return FILTER_ERROR; | 91 return FILTER_ERROR; |
| 92 | 92 |
| 93 time_of_last_read_ = base::Time::Now(); | 93 // Don't update when we're called to just flush out our internal buffers. |
| 94 if (next_stream_data_ && stream_data_len_ > 0) |
| 95 time_of_last_read_ = base::Time::Now(); |
| 94 | 96 |
| 95 if (WAITING_FOR_DICTIONARY_SELECTION == decoding_status_) { | 97 if (WAITING_FOR_DICTIONARY_SELECTION == decoding_status_) { |
| 96 FilterStatus status = InitializeDictionary(); | 98 FilterStatus status = InitializeDictionary(); |
| 97 if (FILTER_NEED_MORE_DATA == status) | 99 if (FILTER_NEED_MORE_DATA == status) |
| 98 return FILTER_NEED_MORE_DATA; | 100 return FILTER_NEED_MORE_DATA; |
| 99 if (FILTER_ERROR == status) { | 101 if (FILTER_ERROR == status) { |
| 100 DCHECK(DECODING_ERROR == decoding_status_); | 102 DCHECK(DECODING_ERROR == decoding_status_); |
| 101 DCHECK(0 == dest_buffer_excess_index_); | 103 DCHECK(0 == dest_buffer_excess_index_); |
| 102 DCHECK(dest_buffer_excess_.empty()); | 104 DCHECK(dest_buffer_excess_.empty()); |
| 103 if (!dictionary_hash_is_plausible_) { | 105 if (!dictionary_hash_is_plausible_) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, | 241 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, |
| 240 amount); | 242 amount); |
| 241 dest_buffer_excess_index_ += amount; | 243 dest_buffer_excess_index_ += amount; |
| 242 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { | 244 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { |
| 243 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); | 245 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); |
| 244 dest_buffer_excess_.clear(); | 246 dest_buffer_excess_.clear(); |
| 245 dest_buffer_excess_index_ = 0; | 247 dest_buffer_excess_index_ = 0; |
| 246 } | 248 } |
| 247 return amount; | 249 return amount; |
| 248 } | 250 } |
| OLD | NEW |