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

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: Created 3 years, 9 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
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 RecordDownloadCount(INTERRUPTED_COUNT); 393 bool uses_parallel_requests) {
394 if (uses_parallel_requests)
395 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_INTERRUPTED_COUNT);
396 else
397 RecordDownloadCount(INTERRUPTED_COUNT);
398
399 std::string histogram_name = uses_parallel_requests ?
400 "Download.ParallelDownloadInterruptedReason" :
401 "Download.InterruptedReason";
402
394 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 403 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
395 "Download.InterruptedReason", 404 histogram_name,
396 reason, 405 reason,
397 base::CustomHistogram::ArrayToCustomRanges( 406 base::CustomHistogram::ArrayToCustomRanges(
398 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes))); 407 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes)));
399 408
400 // The maximum should be 2^kBuckets, to have the logarithmic bucket 409 // The maximum should be 2^kBuckets, to have the logarithmic bucket
401 // boundaries fall on powers of 2. 410 // boundaries fall on powers of 2.
402 static const int kBuckets = 30; 411 static const int kBuckets = 30;
403 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. 412 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes.
404 int64_t delta_bytes = total - received; 413 int64_t delta_bytes = total - received;
405 bool unknown_size = total <= 0; 414 bool unknown_size = total <= 0;
406 int64_t received_kb = received / 1024; 415 int64_t received_kb = received / 1024;
407 int64_t total_kb = total / 1024; 416 int64_t total_kb = total / 1024;
408 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", 417 histogram_name = uses_parallel_requests ?
418 "Download.ParallelDownloadInterruptedReceivedSizeK" :
419 "Download.InterruptedReceivedSizeK";
420
421 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_name,
409 received_kb, 422 received_kb,
410 1, 423 1,
411 kMaxKb, 424 kMaxKb,
412 kBuckets); 425 kBuckets);
413 if (!unknown_size) { 426 if (!unknown_size) {
414 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", 427 histogram_name = uses_parallel_requests ?
428 "Download.ParallelDownloadInterruptedTotalSizeK" :
429 "Download.InterruptedTotalSizeK";
430 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_name,
415 total_kb, 431 total_kb,
416 1, 432 1,
417 kMaxKb, 433 kMaxKb,
418 kBuckets); 434 kBuckets);
419 if (delta_bytes == 0) { 435 if (delta_bytes == 0) {
420 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); 436 if (uses_parallel_requests)
437 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_INTERRUPTED_AT_END_COUNT);
438 else
439 RecordDownloadCount(INTERRUPTED_AT_END_COUNT);
440 histogram_name = uses_parallel_requests ?
441 "Download.ParallelDownloadInterruptedAtEndReason" :
442 "Download.InterruptedAtEndReason";
421 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 443 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
422 "Download.InterruptedAtEndReason", 444 histogram_name,
423 reason, 445 reason,
424 base::CustomHistogram::ArrayToCustomRanges( 446 base::CustomHistogram::ArrayToCustomRanges(
425 kAllInterruptReasonCodes, 447 kAllInterruptReasonCodes,
426 arraysize(kAllInterruptReasonCodes))); 448 arraysize(kAllInterruptReasonCodes)));
427 } else if (delta_bytes > 0) { 449 } else if (delta_bytes > 0) {
428 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", 450 histogram_name = uses_parallel_requests ?
451 "Download.ParallelDownloadInterruptedOverrunBytes" :
452 "Download.InterruptedOverrunBytes";
453 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_name,
429 delta_bytes, 454 delta_bytes,
430 1, 455 1,
431 kMaxKb, 456 kMaxKb,
432 kBuckets); 457 kBuckets);
433 } else { 458 } else {
434 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedUnderrunBytes", 459 histogram_name = uses_parallel_requests ?
460 "Download.ParallelDownloadInterruptedUnderrunBytes" :
461 "Download.InterruptedUnderrunBytes";
462 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_name,
435 -delta_bytes, 463 -delta_bytes,
436 1, 464 1,
437 kMaxKb, 465 kMaxKb,
438 kBuckets); 466 kBuckets);
439 } 467 }
440 } 468 }
441 469
442 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size); 470 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size);
443 } 471 }
444 472
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 void RecordFileBandwidth(size_t length, 747 void RecordFileBandwidth(size_t length,
720 base::TimeDelta disk_write_time, 748 base::TimeDelta disk_write_time,
721 base::TimeDelta elapsed_time) { 749 base::TimeDelta elapsed_time) {
722 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", 750 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond",
723 CalculateBandwidthBytesPerSecond(length, elapsed_time)); 751 CalculateBandwidthBytesPerSecond(length, elapsed_time));
724 RecordBandwidthMetric( 752 RecordBandwidthMetric(
725 "Download.BandwidthDiskBytesPerSecond", 753 "Download.BandwidthDiskBytesPerSecond",
726 CalculateBandwidthBytesPerSecond(length, disk_write_time)); 754 CalculateBandwidthBytesPerSecond(length, disk_write_time));
727 } 755 }
728 756
757 void RecordParallelDownloadCount(ParallelDownloadCountTypes type) {
758 UMA_HISTOGRAM_ENUMERATION(
759 "Download.ParallelDownloadCounts", type,
760 PARALLEL_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
761 }
762
729 void RecordParallelDownloadStats( 763 void RecordParallelDownloadStats(
730 size_t bytes_downloaded_with_parallel_streams, 764 size_t bytes_downloaded_with_parallel_streams,
731 base::TimeDelta time_with_parallel_streams, 765 base::TimeDelta time_with_parallel_streams,
732 size_t bytes_downloaded_without_parallel_streams, 766 size_t bytes_downloaded_without_parallel_streams,
733 base::TimeDelta time_without_parallel_streams) { 767 base::TimeDelta time_without_parallel_streams) {
734 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( 768 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond(
735 bytes_downloaded_without_parallel_streams, time_without_parallel_streams); 769 bytes_downloaded_without_parallel_streams, time_without_parallel_streams);
736 RecordBandwidthMetric( 770 RecordBandwidthMetric(
737 "Download.BandwidthWithoutParallelStreamsBytesPerSecond", 771 "Download.BandwidthWithoutParallelStreamsBytesPerSecond",
738 bandwidth_without_parallel_streams); 772 bandwidth_without_parallel_streams);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 if (!page_transition) 872 if (!page_transition)
839 return; 873 return;
840 874
841 UMA_HISTOGRAM_ENUMERATION( 875 UMA_HISTOGRAM_ENUMERATION(
842 "Download.PageTransition", 876 "Download.PageTransition",
843 ui::PageTransitionStripQualifier(page_transition.value()), 877 ui::PageTransitionStripQualifier(page_transition.value()),
844 ui::PAGE_TRANSITION_LAST_CORE + 1); 878 ui::PAGE_TRANSITION_LAST_CORE + 1);
845 } 879 }
846 880
847 } // namespace content 881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698