OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/filter/brotli_filter.h" | 5 #include "net/filter/brotli_filter.h" |
6 | 6 |
7 #include "base/bit_cast.h" | 7 #include "base/bit_cast.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 ~BrotliFilter() override { | 35 ~BrotliFilter() override { |
36 BrotliDestroyState(brotli_state_); | 36 BrotliDestroyState(brotli_state_); |
37 brotli_state_ = nullptr; | 37 brotli_state_ = nullptr; |
38 DCHECK(used_memory_ == 0); | 38 DCHECK(used_memory_ == 0); |
39 | 39 |
40 UMA_HISTOGRAM_ENUMERATION( | 40 UMA_HISTOGRAM_ENUMERATION( |
41 "BrotliFilter.Status", static_cast<int>(decoding_status_), | 41 "BrotliFilter.Status", static_cast<int>(decoding_status_), |
42 static_cast<int>(DecodingStatus::DECODING_STATUS_COUNT)); | 42 static_cast<int>(DecodingStatus::DECODING_STATUS_COUNT)); |
43 if (decoding_status_ == DecodingStatus::DECODING_DONE) { | 43 if (decoding_status_ == DecodingStatus::DECODING_DONE) { |
44 UMA_HISTOGRAM_PERCENTAGE( | 44 // CompressionPercent is undefined when there is no output produced. |
45 "BrotliFilter.CompressionPercent", | 45 if (produced_bytes_ != 0) { |
46 static_cast<int>((consumed_bytes_ * 100) / produced_bytes_)); | 46 UMA_HISTOGRAM_PERCENTAGE( |
| 47 "BrotliFilter.CompressionPercent", |
| 48 static_cast<int>((consumed_bytes_ * 100) / produced_bytes_)); |
| 49 } |
47 } | 50 } |
48 | 51 |
49 // All code here is for gathering stats, and can be removed when | 52 // All code here is for gathering stats, and can be removed when |
50 // BrotliFilter is considered stable. | 53 // BrotliFilter is considered stable. |
51 static const int kBuckets = 48; | 54 static const int kBuckets = 48; |
52 static const int64_t kMaxKb = 1 << (kBuckets / 3); // 64MiB in KiB | 55 static const int64_t kMaxKb = 1 << (kBuckets / 3); // 64MiB in KiB |
53 UMA_HISTOGRAM_CUSTOM_COUNTS("BrotliFilter.UsedMemoryKB", | 56 UMA_HISTOGRAM_CUSTOM_COUNTS("BrotliFilter.UsedMemoryKB", |
54 used_memory_maximum_ / 1024, 1, kMaxKb, | 57 used_memory_maximum_ / 1024, 1, kMaxKb, |
55 kBuckets); | 58 kBuckets); |
56 } | 59 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 size_t produced_bytes_; | 181 size_t produced_bytes_; |
179 | 182 |
180 DISALLOW_COPY_AND_ASSIGN(BrotliFilter); | 183 DISALLOW_COPY_AND_ASSIGN(BrotliFilter); |
181 }; | 184 }; |
182 | 185 |
183 Filter* CreateBrotliFilter(Filter::FilterType type_id) { | 186 Filter* CreateBrotliFilter(Filter::FilterType type_id) { |
184 return new BrotliFilter(type_id); | 187 return new BrotliFilter(type_id); |
185 } | 188 } |
186 | 189 |
187 } // namespace net | 190 } // namespace net |
OLD | NEW |