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

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 1888043002: Differentiate between small and large images in caching metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/http/http_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" // For OS_POSIX 7 #include "build/build_config.h" // For OS_POSIX
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 2699
2700 void HttpCache::Transaction::RecordHistograms() { 2700 void HttpCache::Transaction::RecordHistograms() {
2701 DCHECK_NE(PATTERN_UNDEFINED, transaction_pattern_); 2701 DCHECK_NE(PATTERN_UNDEFINED, transaction_pattern_);
2702 if (!cache_.get() || !cache_->GetCurrentBackend() || 2702 if (!cache_.get() || !cache_->GetCurrentBackend() ||
2703 cache_->GetCurrentBackend()->GetCacheType() != DISK_CACHE || 2703 cache_->GetCurrentBackend()->GetCacheType() != DISK_CACHE ||
2704 cache_->mode() != NORMAL || request_->method != "GET") { 2704 cache_->mode() != NORMAL || request_->method != "GET") {
2705 return; 2705 return;
2706 } 2706 }
2707 2707
2708 std::string mime_type; 2708 std::string mime_type;
2709 if (GetResponseInfo()->headers && 2709 HttpResponseHeaders* response_headers = GetResponseInfo()->headers.get();
2710 GetResponseInfo()->headers->GetMimeType(&mime_type)) { 2710 if (response_headers && response_headers->GetMimeType(&mime_type)) {
2711 // Record the cache pattern by resource type. The type is inferred by 2711 // Record the cache pattern by resource type. The type is inferred by
2712 // response header mime type, which could be incorrect, so this is just an 2712 // response header mime type, which could be incorrect, so this is just an
2713 // estimate. 2713 // estimate.
2714 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) { 2714 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) {
2715 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.MainFrameHTML"), 2715 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.MainFrameHTML"),
2716 transaction_pattern_, PATTERN_MAX); 2716 transaction_pattern_, PATTERN_MAX);
2717 } else if (mime_type == "text/html") { 2717 } else if (mime_type == "text/html") {
2718 UMA_HISTOGRAM_ENUMERATION( 2718 UMA_HISTOGRAM_ENUMERATION(
2719 std::string("HttpCache.Pattern.NonMainFrameHTML"), 2719 std::string("HttpCache.Pattern.NonMainFrameHTML"),
2720 transaction_pattern_, PATTERN_MAX); 2720 transaction_pattern_, PATTERN_MAX);
2721 } else if (mime_type == "text/css") { 2721 } else if (mime_type == "text/css") {
2722 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.CSS"), 2722 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.CSS"),
2723 transaction_pattern_, PATTERN_MAX); 2723 transaction_pattern_, PATTERN_MAX);
2724 } else if (base::StartsWith(mime_type, "image/", 2724 } else if (base::StartsWith(mime_type, "image/",
2725 base::CompareCase::SENSITIVE)) { 2725 base::CompareCase::SENSITIVE)) {
2726 if (response_headers->GetContentLength() < 100) {
Deprecated (see juliatuttle) 2016/04/14 14:11:33 GetContentLength returns -1 if there is no Content
jkarlin 2016/04/14 14:28:52 Good point, better to skip them. Done.
2727 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.TinyImage"),
2728 transaction_pattern_, PATTERN_MAX);
2729 } else {
2730 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.NonTinyImage"),
2731 transaction_pattern_, PATTERN_MAX);
2732 }
2726 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Image"), 2733 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Image"),
2727 transaction_pattern_, PATTERN_MAX); 2734 transaction_pattern_, PATTERN_MAX);
2728 } else if (base::EndsWith(mime_type, "javascript", 2735 } else if (base::EndsWith(mime_type, "javascript",
2729 base::CompareCase::SENSITIVE) || 2736 base::CompareCase::SENSITIVE) ||
2730 base::EndsWith(mime_type, "ecmascript", 2737 base::EndsWith(mime_type, "ecmascript",
2731 base::CompareCase::SENSITIVE)) { 2738 base::CompareCase::SENSITIVE)) {
2732 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.JavaScript"), 2739 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.JavaScript"),
2733 transaction_pattern_, PATTERN_MAX); 2740 transaction_pattern_, PATTERN_MAX);
2734 } else if (mime_type.find("font") != std::string::npos) { 2741 } else if (mime_type.find("font") != std::string::npos) {
2735 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Font"), 2742 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Font"),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 default: 2814 default:
2808 NOTREACHED(); 2815 NOTREACHED();
2809 } 2816 }
2810 } 2817 }
2811 2818
2812 void HttpCache::Transaction::OnIOComplete(int result) { 2819 void HttpCache::Transaction::OnIOComplete(int result) {
2813 DoLoop(result); 2820 DoLoop(result);
2814 } 2821 }
2815 2822
2816 } // namespace net 2823 } // namespace net
OLDNEW
« 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