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

Unified Diff: content/browser/download/download_stats.cc

Issue 2798723002: Fix the UMA stats calculation because of overflow (Closed)
Patch Set: Created 3 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_stats.cc
diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc
index 3fcff94ed6e5de4685d2882b858da4f8f7c4e674..8951352311925039ec71243743003397cc16a37f 100644
--- a/content/browser/download/download_stats.cc
+++ b/content/browser/download/download_stats.cc
@@ -348,13 +348,12 @@ int GetDangerousFileType(const base::FilePath& file_path) {
}
// Helper method to calculate the bandwidth given the data length and time.
-int CalculateBandwidthBytesPerSecond(size_t length,
- base::TimeDelta elapsed_time) {
- size_t elapsed_time_ms = elapsed_time.InMilliseconds();
- if (0u == elapsed_time_ms)
+int64_t CalculateBandwidthBytesPerSecond(size_t length,
+ base::TimeDelta elapsed_time) {
+ int64_t elapsed_time_ms = elapsed_time.InMilliseconds();
+ if (0 == elapsed_time_ms)
elapsed_time_ms = 1;
-
- return 1000 * length / elapsed_time_ms;
+ return 1000 * static_cast<int64_t>(length) / elapsed_time_ms;
}
// Helper method to record the bandwidth for a given metric.
@@ -778,7 +777,7 @@ void RecordParallelDownloadStats(
base::TimeDelta time_with_parallel_streams,
size_t bytes_downloaded_without_parallel_streams,
base::TimeDelta time_without_parallel_streams) {
- int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond(
+ int64_t bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond(
bytes_downloaded_without_parallel_streams, time_without_parallel_streams);
RecordBandwidthMetric(
"Download.BandwidthWithoutParallelStreamsBytesPerSecond",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698