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

Unified Diff: net/http/http_cache_transaction.cc

Issue 1824713002: Break down HTTPCache.Result metric by resource type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ecmascript Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 38da8f3bd7b0fc8a7492cef49a0666fd027c8668..178df98d6e1a1876fc748eb89d4bb43202fb284a 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -2704,6 +2704,39 @@ void HttpCache::Transaction::RecordHistograms() {
cache_->mode() != NORMAL || request_->method != "GET") {
return;
}
+
+ std::string mime_type;
+ if (GetResponseInfo()->headers &&
+ GetResponseInfo()->headers->GetMimeType(&mime_type)) {
+ // Record the cache pattern by resource type. The type is inferred by
+ // response header mime type, which could be incorrect, so this is just an
+ // estimate.
+ if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) {
+ UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.MainFrameHTML"),
+ transaction_pattern_, PATTERN_MAX);
+ } else if (mime_type == "text/html") {
+ UMA_HISTOGRAM_ENUMERATION(
+ std::string("HttpCache.Pattern.NonMainFrameHTML"),
+ transaction_pattern_, PATTERN_MAX);
+ } else if (mime_type == "text/css") {
+ UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.CSS"),
+ transaction_pattern_, PATTERN_MAX);
+ } else if (base::StartsWith(mime_type, "image/",
+ base::CompareCase::SENSITIVE)) {
+ UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Image"),
+ transaction_pattern_, PATTERN_MAX);
+ } else if (base::EndsWith(mime_type, "javascript",
+ base::CompareCase::SENSITIVE) ||
+ base::EndsWith(mime_type, "ecmascript",
+ base::CompareCase::SENSITIVE)) {
+ UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.JavaScript"),
+ transaction_pattern_, PATTERN_MAX);
+ } else if (mime_type.find("font") != std::string::npos) {
+ UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Font"),
+ transaction_pattern_, PATTERN_MAX);
+ }
+ }
+
UMA_HISTOGRAM_ENUMERATION(
"HttpCache.Pattern", transaction_pattern_, PATTERN_MAX);
if (transaction_pattern_ == PATTERN_NOT_COVERED)
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698