Index: content/browser/download/download_stats.cc |
diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc |
index 2da505a27a00e85e61d46f28f4c2995e71b8d3ce..52f90a1bdb82d51391b7f703b394480af5faad6e 100644 |
--- a/content/browser/download/download_stats.cc |
+++ b/content/browser/download/download_stats.cc |
@@ -8,9 +8,12 @@ |
#include "base/string_util.h" |
#include "content/browser/download/download_resource_handler.h" |
#include "content/public/browser/download_interrupt_reasons.h" |
+#include "net/http/http_content_disposition.h" |
namespace content { |
+namespace { |
+ |
// All possible error codes from the network module. Note that the error codes |
// are all positive (since histograms expect positive sample values). |
const int kAllInterruptReasonCodes[] = { |
@@ -19,6 +22,45 @@ const int kAllInterruptReasonCodes[] = { |
#undef INTERRUPT_REASON |
}; |
+// These values are based on net::HttpContentDisposition::ParseResult values. |
+// Values other than HEADER_PRESENT and IS_VALID are only measured if |is_valid| |
+// is true. |
+enum ContentDispositionCountTypes { |
+ // Count of downloads which had a Content-Disposition headers. The total |
+ // number of downloads is measured by UNTHROTTLED_COUNT. |
+ CONTENT_DISPOSITION_HEADER_PRESENT = 0, |
+ |
+ // At least one of 'name', 'filename' or 'filenae*' attributes were valid and |
+ // yielded a non-empty filename. |
+ CONTENT_DISPOSITION_IS_VALID, |
+ |
+ // The following enum values correspond to |
+ // net::HttpContentDisposition::ParseResult. |
+ CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, |
+ CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, |
+ CONTENT_DISPOSITION_HAS_NAME, |
+ CONTENT_DISPOSITION_HAS_FILENAME, |
+ CONTENT_DISPOSITION_HAS_EXT_FILENAME, |
+ CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, |
+ CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, |
+ CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, |
+ |
+ // Only have the 'name' attribute is present. |
+ CONTENT_DISPOSITION_HAS_NAME_ONLY, |
+ |
+ CONTENT_DISPOSITION_LAST_ENTRY |
+}; |
+ |
+void RecordContentDispositionCount(ContentDispositionCountTypes type, |
+ bool record) { |
+ if (!record) |
+ return; |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Download.ContentDisposition", type, CONTENT_DISPOSITION_LAST_ENTRY); |
+} |
+ |
+} // namespace |
+ |
void RecordDownloadCount(DownloadCountTypes type) { |
UMA_HISTOGRAM_ENUMERATION( |
"Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); |
@@ -252,6 +294,41 @@ void RecordDownloadMimeType(const std::string& mime_type_string) { |
DOWNLOAD_CONTENT_MAX); |
} |
+void RecordDownloadContentDisposition( |
+ const std::string& content_disposition_string) { |
+ if (content_disposition_string.empty()) |
+ return; |
+ net::HttpContentDisposition content_disposition( |
+ content_disposition_string, ""); |
+ const net::HttpContentDisposition::ParseResult& result = |
+ content_disposition.parse_result(); |
+ |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HEADER_PRESENT, true); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_IS_VALID, |
+ (result.has_name || result.has_filename || |
+ result.has_ext_filename)); |
Randy Smith (Not in Mondays)
2012/12/12 16:10:36
Isn't this contradictory to the comment in the enu
asanka
2012/12/14 01:28:01
Done.
|
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, |
+ result.has_disposition_type); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, |
+ result.has_unknown_disposition_type); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_NAME, |
+ result.has_name); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_FILENAME, |
+ result.has_filename); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_EXT_FILENAME, |
+ result.has_ext_filename); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, |
+ result.has_non_ascii_strings); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, |
+ result.has_percent_encoded_strings); |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, |
+ result.has_rfc2047_encoded_strings); |
+ |
+ RecordContentDispositionCount(CONTENT_DISPOSITION_HAS_NAME_ONLY, |
+ (result.has_name && !result.has_filename && |
+ !result.has_ext_filename)); |
+} |
+ |
void RecordFileThreadReceiveBuffers(size_t num_buffers) { |
UMA_HISTOGRAM_CUSTOM_COUNTS( |
"Download.FileThreadReceiveBuffers", num_buffers, 1, |