summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 16:10:32 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 16:10:32 +0000
commit88cb7aae56fb25519a659599695a38d8822e01f3 (patch)
tree9acb7bcf4391ff08da954923dd76e08116580f18 /content
parent10a99b30934ac4a634486e31a5719b83b6ba7a2b (diff)
downloadchromium_src-88cb7aae56fb25519a659599695a38d8822e01f3.zip
chromium_src-88cb7aae56fb25519a659599695a38d8822e01f3.tar.gz
chromium_src-88cb7aae56fb25519a659599695a38d8822e01f3.tar.bz2
Get more information about types of images being downloaded.
This adds a new enum Download.ContentImageType rather than adding additional entries to Download.ContentType. The downside is that there is a bit more code. The upside is that we don't have to worry about the image entries getting fragmented across the Download.ContentType enum, and there is a top-level entry for images in the Download.ContentType histogram to compare against other general media types. TEST=Download a few images, make sure Download.ContentType and Download.ContentImageType look sane. Review URL: http://codereview.chromium.org/8734006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/download/download_stats.cc46
1 files changed, 44 insertions, 2 deletions
diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc
index b08a9a4..74398e6 100644
--- a/content/browser/download/download_stats.cc
+++ b/content/browser/download/download_stats.cc
@@ -171,6 +171,48 @@ static MimeTypeToDownloadContent kMapMimeTypeToDownloadContent[] = {
{"application/x-chrome-extension", DOWNLOAD_CONTENT_CRX},
};
+enum DownloadImage {
+ DOWNLOAD_IMAGE_UNRECOGNIZED = 0,
+ DOWNLOAD_IMAGE_GIF = 1,
+ DOWNLOAD_IMAGE_JPEG = 2,
+ DOWNLOAD_IMAGE_PNG = 3,
+ DOWNLOAD_IMAGE_TIFF = 4,
+ DOWNLOAD_IMAGE_ICON = 5,
+ DOWNLOAD_IMAGE_WEBP = 6,
+ DOWNLOAD_IMAGE_MAX = 7,
+};
+
+struct MimeTypeToDownloadImage {
+ const char* mime_type;
+ DownloadImage download_image;
+};
+
+static MimeTypeToDownloadImage kMapMimeTypeToDownloadImage[] = {
+ {"image/gif", DOWNLOAD_IMAGE_GIF},
+ {"image/jpeg", DOWNLOAD_IMAGE_JPEG},
+ {"image/png", DOWNLOAD_IMAGE_PNG},
+ {"image/tiff", DOWNLOAD_IMAGE_TIFF},
+ {"image/vnd.microsoft.icon", DOWNLOAD_IMAGE_ICON},
+ {"image/webp", DOWNLOAD_IMAGE_WEBP},
+};
+
+void RecordDownloadImageType(const std::string& mime_type_string) {
+ DownloadImage download_image = DOWNLOAD_IMAGE_UNRECOGNIZED;
+
+ // Look up exact matches.
+ for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadImage); ++i) {
+ const MimeTypeToDownloadImage& entry = kMapMimeTypeToDownloadImage[i];
+ if (mime_type_string == entry.mime_type) {
+ download_image = entry.download_image;
+ break;
+ }
+ }
+
+ UMA_HISTOGRAM_ENUMERATION("Download.ContentImageType",
+ download_image,
+ DOWNLOAD_IMAGE_MAX);
+}
+
} // namespace
void RecordDownloadMimeType(const std::string& mime_type_string) {
@@ -178,8 +220,7 @@ void RecordDownloadMimeType(const std::string& mime_type_string) {
// Look up exact matches.
for (size_t i = 0; i < arraysize(kMapMimeTypeToDownloadContent); ++i) {
- const MimeTypeToDownloadContent& entry =
- kMapMimeTypeToDownloadContent[i];
+ const MimeTypeToDownloadContent& entry = kMapMimeTypeToDownloadContent[i];
if (mime_type_string == entry.mime_type) {
download_content = entry.download_content;
break;
@@ -192,6 +233,7 @@ void RecordDownloadMimeType(const std::string& mime_type_string) {
download_content = DOWNLOAD_CONTENT_TEXT;
} else if (StartsWithASCII(mime_type_string, "image/", true)) {
download_content = DOWNLOAD_CONTENT_IMAGE;
+ RecordDownloadImageType(mime_type_string);
} else if (StartsWithASCII(mime_type_string, "audio/", true)) {
download_content = DOWNLOAD_CONTENT_AUDIO;
} else if (StartsWithASCII(mime_type_string, "video/", true)) {