summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkarlin <jkarlin@chromium.org>2016-03-25 11:36:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-25 18:38:00 +0000
commit5152e48e43339dbe3013b647c00bfff4867eb087 (patch)
tree72535dff5169e99d18db812cc49d0523fe2d7988
parent4a5dd80de434040fa64d2d2d4b35474f8c9f5f70 (diff)
downloadchromium_src-5152e48e43339dbe3013b647c00bfff4867eb087.zip
chromium_src-5152e48e43339dbe3013b647c00bfff4867eb087.tar.gz
chromium_src-5152e48e43339dbe3013b647c00bfff4867eb087.tar.bz2
Break down HTTPCache.Result metric by resource type
We'd like to know how often different resource types are cached and revalidated, so this CL adds cache pattern metrics for common resource types. Note that the resource type is a guess based on the URL's path. There will be many missed resources but I anticipate the fraction of false positives will be low. BUG=596569 Review URL: https://codereview.chromium.org/1824713002 Cr-Commit-Position: refs/heads/master@{#383319}
-rw-r--r--net/http/http_cache_transaction.cc33
-rw-r--r--tools/metrics/histograms/histograms.xml14
2 files changed, 47 insertions, 0 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 38da8f3..178df98 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)
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index f39dc79..4404169e 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -85413,6 +85413,20 @@ To add a new entry, add it with any value and run test to compute valid value.
<affected-histogram name="BlinkGC.CollectionRate"/>
</histogram_suffixes>
+<histogram_suffixes name="CachedResourceType" separator=".">
+ <suffix name="JavaScript"
+ label="Showing cache patterns only for JavaScript resources."/>
+ <suffix name="CSS" label="Showing cache patterns only for CSS resources."/>
+ <suffix name="MainFrameHTML"
+ label="Showing cache patterns only for main-frame HTML resources."/>
+ <suffix name="NonMainFrameHTML"
+ label="Showing cache patterns only for non-main-frame HTML resources."/>
+ <suffix name="Image"
+ label="Showing cache patterns only for image resources."/>
+ <suffix name="Font" label="Showing cache patterns only for font resources."/>
+ <affected-histogram name="HttpCache.Pattern"/>
+</histogram_suffixes>
+
<histogram_suffixes name="CacheInstance" separator="." ordering="prefix">
<suffix name="App"
label="Collected from the HTML5 Application Cache instance."/>