OLD | NEW |
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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 587 |
588 // Look up exact matches. | 588 // Look up exact matches. |
589 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadImage); ++i) { | 589 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadImage); ++i) { |
590 const MimeTypeToDownloadImage& entry = kMapMimeTypeToDownloadImage[i]; | 590 const MimeTypeToDownloadImage& entry = kMapMimeTypeToDownloadImage[i]; |
591 if (mime_type_string == entry.mime_type) { | 591 if (mime_type_string == entry.mime_type) { |
592 download_image = entry.download_image; | 592 download_image = entry.download_image; |
593 break; | 593 break; |
594 } | 594 } |
595 } | 595 } |
596 | 596 |
597 UMA_HISTOGRAM_ENUMERATION("Download.ContentImageType", | 597 UMA_HISTOGRAM_ENUMERATION("Download.ContentImageType", download_image, |
598 download_image, | |
599 DOWNLOAD_IMAGE_MAX); | 598 DOWNLOAD_IMAGE_MAX); |
600 } | 599 } |
601 | 600 |
602 } // namespace | 601 DownloadContent DownloadContentFromMimeType( |
603 | 602 const std::string& mime_type_string) { |
604 void RecordDownloadMimeType(const std::string& mime_type_string) { | |
605 DownloadContent download_content = DOWNLOAD_CONTENT_UNRECOGNIZED; | 603 DownloadContent download_content = DOWNLOAD_CONTENT_UNRECOGNIZED; |
606 | 604 |
607 // Look up exact matches. | 605 // Look up exact matches. |
608 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadContent); ++i) { | 606 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadContent); ++i) { |
609 const MimeTypeToDownloadContent& entry = kMapMimeTypeToDownloadContent[i]; | 607 const MimeTypeToDownloadContent& entry = kMapMimeTypeToDownloadContent[i]; |
610 if (mime_type_string == entry.mime_type) { | 608 if (mime_type_string == entry.mime_type) { |
611 download_content = entry.download_content; | 609 download_content = entry.download_content; |
612 break; | 610 break; |
613 } | 611 } |
614 } | 612 } |
615 | 613 |
616 // Do partial matches. | 614 // Do partial matches. |
617 if (download_content == DOWNLOAD_CONTENT_UNRECOGNIZED) { | 615 if (download_content == DOWNLOAD_CONTENT_UNRECOGNIZED) { |
618 if (base::StartsWith(mime_type_string, "text/", | 616 if (base::StartsWith(mime_type_string, "text/", |
619 base::CompareCase::SENSITIVE)) { | 617 base::CompareCase::SENSITIVE)) { |
620 download_content = DOWNLOAD_CONTENT_TEXT; | 618 download_content = DOWNLOAD_CONTENT_TEXT; |
621 } else if (base::StartsWith(mime_type_string, "image/", | 619 } else if (base::StartsWith(mime_type_string, "image/", |
622 base::CompareCase::SENSITIVE)) { | 620 base::CompareCase::SENSITIVE)) { |
623 download_content = DOWNLOAD_CONTENT_IMAGE; | 621 download_content = DOWNLOAD_CONTENT_IMAGE; |
624 RecordDownloadImageType(mime_type_string); | 622 RecordDownloadImageType(mime_type_string); |
625 } else if (base::StartsWith(mime_type_string, "audio/", | 623 } else if (base::StartsWith(mime_type_string, "audio/", |
626 base::CompareCase::SENSITIVE)) { | 624 base::CompareCase::SENSITIVE)) { |
627 download_content = DOWNLOAD_CONTENT_AUDIO; | 625 download_content = DOWNLOAD_CONTENT_AUDIO; |
628 } else if (base::StartsWith(mime_type_string, "video/", | 626 } else if (base::StartsWith(mime_type_string, "video/", |
629 base::CompareCase::SENSITIVE)) { | 627 base::CompareCase::SENSITIVE)) { |
630 download_content = DOWNLOAD_CONTENT_VIDEO; | 628 download_content = DOWNLOAD_CONTENT_VIDEO; |
631 } | 629 } |
632 } | 630 } |
633 | 631 |
634 // Record the value. | 632 return download_content; |
635 UMA_HISTOGRAM_ENUMERATION("Download.ContentType", | 633 } |
636 download_content, | 634 |
| 635 } // namespace |
| 636 |
| 637 void RecordDownloadMimeType(const std::string& mime_type_string) { |
| 638 UMA_HISTOGRAM_ENUMERATION("Download.Start.ContentType", |
| 639 DownloadContentFromMimeType(mime_type_string), |
637 DOWNLOAD_CONTENT_MAX); | 640 DOWNLOAD_CONTENT_MAX); |
638 } | 641 } |
639 | 642 |
| 643 void RecordDownloadMimeTypeForNormalProfile( |
| 644 const std::string& mime_type_string) { |
| 645 UMA_HISTOGRAM_ENUMERATION("Download.Start.ContentType.NormalProfile", |
| 646 DownloadContentFromMimeType(mime_type_string), |
| 647 DOWNLOAD_CONTENT_MAX); |
| 648 } |
| 649 |
640 void RecordDownloadContentDisposition( | 650 void RecordDownloadContentDisposition( |
641 const std::string& content_disposition_string) { | 651 const std::string& content_disposition_string) { |
642 if (content_disposition_string.empty()) | 652 if (content_disposition_string.empty()) |
643 return; | 653 return; |
644 net::HttpContentDisposition content_disposition(content_disposition_string, | 654 net::HttpContentDisposition content_disposition(content_disposition_string, |
645 std::string()); | 655 std::string()); |
646 int result = content_disposition.parse_result_flags(); | 656 int result = content_disposition.parse_result_flags(); |
647 | 657 |
648 bool is_valid = !content_disposition.filename().empty(); | 658 bool is_valid = !content_disposition.filename().empty(); |
649 RecordContentDispositionCount(CONTENT_DISPOSITION_HEADER_PRESENT, true); | 659 RecordContentDispositionCount(CONTENT_DISPOSITION_HEADER_PRESENT, true); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 if (!page_transition) | 848 if (!page_transition) |
839 return; | 849 return; |
840 | 850 |
841 UMA_HISTOGRAM_ENUMERATION( | 851 UMA_HISTOGRAM_ENUMERATION( |
842 "Download.PageTransition", | 852 "Download.PageTransition", |
843 ui::PageTransitionStripQualifier(page_transition.value()), | 853 ui::PageTransitionStripQualifier(page_transition.value()), |
844 ui::PAGE_TRANSITION_LAST_CORE + 1); | 854 ui::PAGE_TRANSITION_LAST_CORE + 1); |
845 } | 855 } |
846 | 856 |
847 } // namespace content | 857 } // namespace content |
OLD | NEW |