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

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

Issue 2758453003: Recording download mime types for normal profile (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_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 download_image = entry.download_image; 576 download_image = entry.download_image;
577 break; 577 break;
578 } 578 }
579 } 579 }
580 580
581 UMA_HISTOGRAM_ENUMERATION("Download.ContentImageType", 581 UMA_HISTOGRAM_ENUMERATION("Download.ContentImageType",
582 download_image, 582 download_image,
583 DOWNLOAD_IMAGE_MAX); 583 DOWNLOAD_IMAGE_MAX);
584 } 584 }
585 585
586 } // namespace 586 DownloadContent DownloadContentTypeFromMimeType(
587 587 const std::string& mime_type_string) {
588 void RecordDownloadMimeType(const std::string& mime_type_string) {
589 DownloadContent download_content = DOWNLOAD_CONTENT_UNRECOGNIZED; 588 DownloadContent download_content = DOWNLOAD_CONTENT_UNRECOGNIZED;
590 589
591 // Look up exact matches. 590 // Look up exact matches.
592 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadContent); ++i) { 591 for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadContent); ++i) {
593 const MimeTypeToDownloadContent& entry = kMapMimeTypeToDownloadContent[i]; 592 const MimeTypeToDownloadContent& entry = kMapMimeTypeToDownloadContent[i];
594 if (mime_type_string == entry.mime_type) { 593 if (mime_type_string == entry.mime_type) {
595 download_content = entry.download_content; 594 download_content = entry.download_content;
596 break; 595 break;
597 } 596 }
598 } 597 }
599 598
600 // Do partial matches. 599 // Do partial matches.
601 if (download_content == DOWNLOAD_CONTENT_UNRECOGNIZED) { 600 if (download_content == DOWNLOAD_CONTENT_UNRECOGNIZED) {
602 if (base::StartsWith(mime_type_string, "text/", 601 if (base::StartsWith(mime_type_string, "text/",
603 base::CompareCase::SENSITIVE)) { 602 base::CompareCase::SENSITIVE)) {
604 download_content = DOWNLOAD_CONTENT_TEXT; 603 download_content = DOWNLOAD_CONTENT_TEXT;
605 } else if (base::StartsWith(mime_type_string, "image/", 604 } else if (base::StartsWith(mime_type_string, "image/",
606 base::CompareCase::SENSITIVE)) { 605 base::CompareCase::SENSITIVE)) {
607 download_content = DOWNLOAD_CONTENT_IMAGE; 606 download_content = DOWNLOAD_CONTENT_IMAGE;
608 RecordDownloadImageType(mime_type_string); 607 RecordDownloadImageType(mime_type_string);
609 } else if (base::StartsWith(mime_type_string, "audio/", 608 } else if (base::StartsWith(mime_type_string, "audio/",
610 base::CompareCase::SENSITIVE)) { 609 base::CompareCase::SENSITIVE)) {
611 download_content = DOWNLOAD_CONTENT_AUDIO; 610 download_content = DOWNLOAD_CONTENT_AUDIO;
612 } else if (base::StartsWith(mime_type_string, "video/", 611 } else if (base::StartsWith(mime_type_string, "video/",
613 base::CompareCase::SENSITIVE)) { 612 base::CompareCase::SENSITIVE)) {
614 download_content = DOWNLOAD_CONTENT_VIDEO; 613 download_content = DOWNLOAD_CONTENT_VIDEO;
615 } 614 }
616 } 615 }
617 616
617 return download_content;
618 }
619
620 } // namespace
621
622 void RecordDownloadMimeType(const std::string& mime_type_string) {
623 DownloadContent download_content =
624 DownloadContentTypeFromMimeType(mime_type_string);
625
618 // Record the value. 626 // Record the value.
619 UMA_HISTOGRAM_ENUMERATION("Download.ContentType", 627 UMA_HISTOGRAM_ENUMERATION("Download.ContentType", download_content,
620 download_content,
621 DOWNLOAD_CONTENT_MAX); 628 DOWNLOAD_CONTENT_MAX);
622 } 629 }
623 630
631 void RecordDownloadMimeTypeForNormalProfile(
632 const std::string& mime_type_string) {
633 DownloadContent download_content =
634 DownloadContentTypeFromMimeType(mime_type_string);
635
636 // Record the value.
637 UMA_HISTOGRAM_ENUMERATION("Download.ContentType.NonOffTheRecord",
638 download_content, DOWNLOAD_CONTENT_MAX);
639 }
640
624 void RecordDownloadContentDisposition( 641 void RecordDownloadContentDisposition(
625 const std::string& content_disposition_string) { 642 const std::string& content_disposition_string) {
626 if (content_disposition_string.empty()) 643 if (content_disposition_string.empty())
627 return; 644 return;
628 net::HttpContentDisposition content_disposition(content_disposition_string, 645 net::HttpContentDisposition content_disposition(content_disposition_string,
629 std::string()); 646 std::string());
630 int result = content_disposition.parse_result_flags(); 647 int result = content_disposition.parse_result_flags();
631 648
632 bool is_valid = !content_disposition.filename().empty(); 649 bool is_valid = !content_disposition.filename().empty();
633 RecordContentDispositionCount(CONTENT_DISPOSITION_HEADER_PRESENT, true); 650 RecordContentDispositionCount(CONTENT_DISPOSITION_HEADER_PRESENT, true);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 if (!page_transition) 812 if (!page_transition)
796 return; 813 return;
797 814
798 UMA_HISTOGRAM_ENUMERATION( 815 UMA_HISTOGRAM_ENUMERATION(
799 "Download.PageTransition", 816 "Download.PageTransition",
800 ui::PageTransitionStripQualifier(page_transition.value()), 817 ui::PageTransitionStripQualifier(page_transition.value()),
801 ui::PAGE_TRANSITION_LAST_CORE + 1); 818 ui::PAGE_TRANSITION_LAST_CORE + 1);
802 } 819 }
803 820
804 } // namespace content 821 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698