Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1527)

Unified Diff: net/filter/brotli_filter.cc

Issue 1616863002: Fix division by zero. Test filter with empty output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/filter/brotli_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/brotli_filter.cc
diff --git a/net/filter/brotli_filter.cc b/net/filter/brotli_filter.cc
index 91ff257b13bd1d4d347d09996c816e420d7e3de8..7ce402ecb684358ff35db3193c6383ac927f3779 100644
--- a/net/filter/brotli_filter.cc
+++ b/net/filter/brotli_filter.cc
@@ -41,9 +41,12 @@ class BrotliFilter : public Filter {
"BrotliFilter.Status", static_cast<int>(decoding_status_),
static_cast<int>(DecodingStatus::DECODING_STATUS_COUNT));
if (decoding_status_ == DecodingStatus::DECODING_DONE) {
- UMA_HISTOGRAM_PERCENTAGE(
- "BrotliFilter.CompressionPercent",
- static_cast<int>((consumed_bytes_ * 100) / produced_bytes_));
+ // CompressionPercent is undefined when there is no output produced.
+ if (produced_bytes_ != 0) {
+ UMA_HISTOGRAM_PERCENTAGE(
+ "BrotliFilter.CompressionPercent",
+ static_cast<int>((consumed_bytes_ * 100) / produced_bytes_));
+ }
}
// All code here is for gathering stats, and can be removed when
« no previous file with comments | « no previous file | net/filter/brotli_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698