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" |
11 #include "net/base/sdch_filter.h" | 11 #include "net/base/sdch_filter.h" |
12 #include "net/base/sdch_manager.h" | 12 #include "net/base/sdch_manager.h" |
13 | 13 |
14 #include "sdch/open-vcdiff/src/google/vcdecoder.h" | 14 #include "sdch/open-vcdiff/src/google/vcdecoder.h" |
15 | 15 |
16 SdchFilter::SdchFilter() | 16 SdchFilter::SdchFilter() |
17 : decoding_status_(DECODING_UNINITIALIZED), | 17 : decoding_status_(DECODING_UNINITIALIZED), |
18 vcdiff_streaming_decoder_(NULL), | 18 vcdiff_streaming_decoder_(NULL), |
19 dictionary_hash_(), | 19 dictionary_hash_(), |
20 dictionary_hash_is_plausible_(false), | 20 dictionary_hash_is_plausible_(false), |
21 dictionary_(NULL), | 21 dictionary_(NULL), |
22 dest_buffer_excess_(), | 22 dest_buffer_excess_(), |
23 dest_buffer_excess_index_(0), | 23 dest_buffer_excess_index_(0), |
24 source_bytes_(0), | 24 source_bytes_(0), |
25 output_bytes_(0), | 25 output_bytes_(0), |
26 time_of_last_read_() { | 26 time_of_last_read_(), |
| 27 size_of_last_read_(0) { |
27 } | 28 } |
28 | 29 |
29 SdchFilter::~SdchFilter() { | 30 SdchFilter::~SdchFilter() { |
30 static int filter_use_count = 0; | 31 static int filter_use_count = 0; |
31 ++filter_use_count; | 32 ++filter_use_count; |
32 if (META_REFRESH_RECOVERY == decoding_status_) { | 33 if (META_REFRESH_RECOVERY == decoding_status_) { |
33 UMA_HISTOGRAM_COUNTS(L"Sdch.FilterUseBeforeDisabling", filter_use_count); | 34 UMA_HISTOGRAM_COUNTS(L"Sdch.FilterUseBeforeDisabling", filter_use_count); |
34 } | 35 } |
35 | 36 |
36 if (vcdiff_streaming_decoder_.get()) { | 37 if (vcdiff_streaming_decoder_.get()) { |
(...skipping 10 matching lines...) Expand all Loading... |
47 // discard bogus large numbers. Note that IF the number is large enough, it | 48 // 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 | 49 // 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 | 50 // relatively precise histogram only properly covers the range 1ms to 10 |
50 // seconds, so the discarded data would not be that readable anyway. | 51 // seconds, so the discarded data would not be that readable anyway. |
51 if (180 >= duration.InSeconds()) { | 52 if (180 >= duration.InSeconds()) { |
52 if (DECODING_IN_PROGRESS == decoding_status_) | 53 if (DECODING_IN_PROGRESS == decoding_status_) |
53 UMA_HISTOGRAM_MEDIUM_TIMES(L"Sdch.Transit_Latency_M", duration); | 54 UMA_HISTOGRAM_MEDIUM_TIMES(L"Sdch.Transit_Latency_M", duration); |
54 if (PASS_THROUGH == decoding_status_) | 55 if (PASS_THROUGH == decoding_status_) |
55 UMA_HISTOGRAM_MEDIUM_TIMES(L"Sdch.Transit_Pass-through_Latency_M", | 56 UMA_HISTOGRAM_MEDIUM_TIMES(L"Sdch.Transit_Pass-through_Latency_M", |
56 duration); | 57 duration); |
| 58 // Look at sizes of the 20% of blocks that arrive with large latency. |
| 59 if (15 < duration.InSeconds()) |
| 60 UMA_HISTOGRAM_COUNTS(L"Sdch.Transit_Belated_Final_Block_Size", |
| 61 size_of_last_read_); |
57 } | 62 } |
58 } | 63 } |
59 | 64 |
60 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes read", source_bytes_); | 65 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes read", source_bytes_); |
61 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes output", output_bytes_); | 66 UMA_HISTOGRAM_COUNTS(L"Sdch.Bytes output", output_bytes_); |
62 | 67 |
63 if (dictionary_) | 68 if (dictionary_) |
64 dictionary_->Release(); | 69 dictionary_->Release(); |
65 } | 70 } |
66 | 71 |
(...skipping 18 matching lines...) Expand all Loading... |
85 | 90 |
86 Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, | 91 Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, |
87 int* dest_len) { | 92 int* dest_len) { |
88 int available_space = *dest_len; | 93 int available_space = *dest_len; |
89 *dest_len = 0; // Nothing output yet. | 94 *dest_len = 0; // Nothing output yet. |
90 | 95 |
91 if (!dest_buffer || available_space <= 0) | 96 if (!dest_buffer || available_space <= 0) |
92 return FILTER_ERROR; | 97 return FILTER_ERROR; |
93 | 98 |
94 // Don't update when we're called to just flush out our internal buffers. | 99 // Don't update when we're called to just flush out our internal buffers. |
95 if (next_stream_data_ && stream_data_len_ > 0) | 100 if (next_stream_data_ && stream_data_len_ > 0) { |
96 time_of_last_read_ = base::Time::Now(); | 101 time_of_last_read_ = base::Time::Now(); |
| 102 size_of_last_read_ = stream_data_len_; |
| 103 } |
97 | 104 |
98 if (WAITING_FOR_DICTIONARY_SELECTION == decoding_status_) { | 105 if (WAITING_FOR_DICTIONARY_SELECTION == decoding_status_) { |
99 FilterStatus status = InitializeDictionary(); | 106 FilterStatus status = InitializeDictionary(); |
100 if (FILTER_NEED_MORE_DATA == status) | 107 if (FILTER_NEED_MORE_DATA == status) |
101 return FILTER_NEED_MORE_DATA; | 108 return FILTER_NEED_MORE_DATA; |
102 if (FILTER_ERROR == status) { | 109 if (FILTER_ERROR == status) { |
103 DCHECK(DECODING_ERROR == decoding_status_); | 110 DCHECK(DECODING_ERROR == decoding_status_); |
104 DCHECK(0 == dest_buffer_excess_index_); | 111 DCHECK(0 == dest_buffer_excess_index_); |
105 DCHECK(dest_buffer_excess_.empty()); | 112 DCHECK(dest_buffer_excess_.empty()); |
106 if (!dictionary_hash_is_plausible_) { | 113 if (!dictionary_hash_is_plausible_) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, | 253 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, |
247 amount); | 254 amount); |
248 dest_buffer_excess_index_ += amount; | 255 dest_buffer_excess_index_ += amount; |
249 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { | 256 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { |
250 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); | 257 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); |
251 dest_buffer_excess_.clear(); | 258 dest_buffer_excess_.clear(); |
252 dest_buffer_excess_index_ = 0; | 259 dest_buffer_excess_index_ = 0; |
253 } | 260 } |
254 return amount; | 261 return amount; |
255 } | 262 } |
OLD | NEW |