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

Side by Side Diff: content/browser/download/download_stats.cc

Issue 2769933003: Add more UMA to record whether parallel download is completed/interrupted/cancelled (Closed)
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « content/browser/download/download_stats.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/download/download_stats.h" 5 #include "content/browser/download/download_stats.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/histogram_functions.h" 8 #include "base/metrics/histogram_functions.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 download_len /= 1024; // In Kilobytes 382 download_len /= 1024; // In Kilobytes
383 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", 383 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize",
384 download_len, 384 download_len,
385 1, 385 1,
386 max, 386 max,
387 256); 387 256);
388 } 388 }
389 389
390 void RecordDownloadInterrupted(DownloadInterruptReason reason, 390 void RecordDownloadInterrupted(DownloadInterruptReason reason,
391 int64_t received, 391 int64_t received,
392 int64_t total) { 392 int64_t total,
393 bool uses_parallel_requests) {
393 RecordDownloadCount(INTERRUPTED_COUNT); 394 RecordDownloadCount(INTERRUPTED_COUNT);
394 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 395 if (uses_parallel_requests)
395 "Download.InterruptedReason", 396 RecordParallelDownloadCount(INTERRUPTED_COUNT);
396 reason, 397
398 std::vector<base::HistogramBase::Sample> samples =
397 base::CustomHistogram::ArrayToCustomRanges( 399 base::CustomHistogram::ArrayToCustomRanges(
398 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes))); 400 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes));
401 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedReason", reason,
402 samples);
403 if (uses_parallel_requests) {
404 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
405 "Download.InterruptedReason.ParallelDownload", reason, samples);
406 }
399 407
400 // The maximum should be 2^kBuckets, to have the logarithmic bucket 408 // The maximum should be 2^kBuckets, to have the logarithmic bucket
401 // boundaries fall on powers of 2. 409 // boundaries fall on powers of 2.
402 static const int kBuckets = 30; 410 static const int kBuckets = 30;
403 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. 411 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes.
404 int64_t delta_bytes = total - received; 412 int64_t delta_bytes = total - received;
405 bool unknown_size = total <= 0; 413 bool unknown_size = total <= 0;
406 int64_t received_kb = received / 1024; 414 int64_t received_kb = received / 1024;
407 int64_t total_kb = total / 1024; 415 int64_t total_kb = total / 1024;
408 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", 416 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK",
409 received_kb, 417 received_kb,
410 1, 418 1,
411 kMaxKb, 419 kMaxKb,
412 kBuckets); 420 kBuckets);
421 if (uses_parallel_requests) {
422 UMA_HISTOGRAM_CUSTOM_COUNTS(
423 "Download.InterruptedReceivedSizeK.ParallelDownload", received_kb, 1,
424 kMaxKb, kBuckets);
425 }
426
413 if (!unknown_size) { 427 if (!unknown_size) {
414 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", 428 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK",
415 total_kb, 429 total_kb,
416 1, 430 1,
417 kMaxKb, 431 kMaxKb,
418 kBuckets); 432 kBuckets);
433 if (uses_parallel_requests) {
434 UMA_HISTOGRAM_CUSTOM_COUNTS(
435 "Download.InterruptedTotalSizeK.ParallelDownload", total_kb, 1,
436 kMaxKb, kBuckets);
437 }
419 if (delta_bytes == 0) { 438 if (delta_bytes == 0) {
420 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); 439 RecordDownloadCount(INTERRUPTED_AT_END_COUNT);
421 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 440 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedAtEndReason",
422 "Download.InterruptedAtEndReason", 441 reason, samples);
423 reason, 442
424 base::CustomHistogram::ArrayToCustomRanges( 443 if (uses_parallel_requests) {
425 kAllInterruptReasonCodes, 444 RecordParallelDownloadCount(INTERRUPTED_AT_END_COUNT);
426 arraysize(kAllInterruptReasonCodes))); 445 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
446 "Download.InterruptedAtEndReason.ParallelDownload", reason,
447 samples);
448 }
427 } else if (delta_bytes > 0) { 449 } else if (delta_bytes > 0) {
428 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", 450 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes",
429 delta_bytes, 451 delta_bytes,
430 1, 452 1,
431 kMaxKb, 453 kMaxKb,
432 kBuckets); 454 kBuckets);
455 if (uses_parallel_requests) {
456 UMA_HISTOGRAM_CUSTOM_COUNTS(
457 "Download.InterruptedOverrunBytes.ParallelDownload", delta_bytes, 1,
458 kMaxKb, kBuckets);
459 }
433 } else { 460 } else {
434 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedUnderrunBytes", 461 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedUnderrunBytes",
435 -delta_bytes, 462 -delta_bytes,
436 1, 463 1,
437 kMaxKb, 464 kMaxKb,
438 kBuckets); 465 kBuckets);
466 if (uses_parallel_requests) {
467 UMA_HISTOGRAM_CUSTOM_COUNTS(
468 "Download.InterruptedUnderrunBytes.ParallelDownload", -delta_bytes,
469 1, kMaxKb, kBuckets);
470 }
439 } 471 }
440 } 472 }
441 473
442 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size); 474 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size);
443 } 475 }
444 476
445 void RecordMaliciousDownloadClassified(DownloadDangerType danger_type) { 477 void RecordMaliciousDownloadClassified(DownloadDangerType danger_type) {
446 UMA_HISTOGRAM_ENUMERATION("Download.MaliciousDownloadClassified", 478 UMA_HISTOGRAM_ENUMERATION("Download.MaliciousDownloadClassified",
447 danger_type, 479 danger_type,
448 DOWNLOAD_DANGER_TYPE_MAX); 480 DOWNLOAD_DANGER_TYPE_MAX);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 void RecordFileBandwidth(size_t length, 761 void RecordFileBandwidth(size_t length,
730 base::TimeDelta disk_write_time, 762 base::TimeDelta disk_write_time,
731 base::TimeDelta elapsed_time) { 763 base::TimeDelta elapsed_time) {
732 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", 764 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond",
733 CalculateBandwidthBytesPerSecond(length, elapsed_time)); 765 CalculateBandwidthBytesPerSecond(length, elapsed_time));
734 RecordBandwidthMetric( 766 RecordBandwidthMetric(
735 "Download.BandwidthDiskBytesPerSecond", 767 "Download.BandwidthDiskBytesPerSecond",
736 CalculateBandwidthBytesPerSecond(length, disk_write_time)); 768 CalculateBandwidthBytesPerSecond(length, disk_write_time));
737 } 769 }
738 770
771 void RecordParallelDownloadCount(DownloadCountTypes type) {
772 UMA_HISTOGRAM_ENUMERATION("Download.Counts.ParallelDownload", type,
773 DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
774 }
775
739 void RecordParallelDownloadStats( 776 void RecordParallelDownloadStats(
740 size_t bytes_downloaded_with_parallel_streams, 777 size_t bytes_downloaded_with_parallel_streams,
741 base::TimeDelta time_with_parallel_streams, 778 base::TimeDelta time_with_parallel_streams,
742 size_t bytes_downloaded_without_parallel_streams, 779 size_t bytes_downloaded_without_parallel_streams,
743 base::TimeDelta time_without_parallel_streams) { 780 base::TimeDelta time_without_parallel_streams) {
744 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( 781 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond(
745 bytes_downloaded_without_parallel_streams, time_without_parallel_streams); 782 bytes_downloaded_without_parallel_streams, time_without_parallel_streams);
746 RecordBandwidthMetric( 783 RecordBandwidthMetric(
747 "Download.BandwidthWithoutParallelStreamsBytesPerSecond", 784 "Download.BandwidthWithoutParallelStreamsBytesPerSecond",
748 bandwidth_without_parallel_streams); 785 bandwidth_without_parallel_streams);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 if (!page_transition) 885 if (!page_transition)
849 return; 886 return;
850 887
851 UMA_HISTOGRAM_ENUMERATION( 888 UMA_HISTOGRAM_ENUMERATION(
852 "Download.PageTransition", 889 "Download.PageTransition",
853 ui::PageTransitionStripQualifier(page_transition.value()), 890 ui::PageTransitionStripQualifier(page_transition.value()),
854 ui::PAGE_TRANSITION_LAST_CORE + 1); 891 ui::PAGE_TRANSITION_LAST_CORE + 1);
855 } 892 }
856 893
857 } // namespace content 894 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_stats.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698