Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2697 transaction_pattern_ = new_transaction_pattern; | 2697 transaction_pattern_ = new_transaction_pattern; |
| 2698 } | 2698 } |
| 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 | |
| 2708 std::string mime_type; | |
| 2709 if (GetResponseInfo()->headers && | |
|
Deprecated (see juliatuttle)
2016/03/23 19:28:48
Do you have a sense from local testing that these
jkarlin
2016/03/24 11:09:00
Nothing extensive, but it seems to have good cover
| |
| 2710 GetResponseInfo()->headers->GetMimeType(&mime_type)) { | |
| 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 | |
| 2713 // estimate. | |
| 2714 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) { | |
| 2715 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.MainFrameHTML"), | |
| 2716 transaction_pattern_, PATTERN_MAX); | |
| 2717 } else if (mime_type == "text/html") { | |
| 2718 UMA_HISTOGRAM_ENUMERATION( | |
| 2719 std::string("HttpCache.Pattern.NonMainFrameHTML"), | |
| 2720 transaction_pattern_, PATTERN_MAX); | |
| 2721 } else if (mime_type == "text/css") { | |
| 2722 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.CSS"), | |
| 2723 transaction_pattern_, PATTERN_MAX); | |
| 2724 } else if (base::StartsWith(mime_type, "image/", | |
| 2725 base::CompareCase::SENSITIVE)) { | |
| 2726 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Image"), | |
| 2727 transaction_pattern_, PATTERN_MAX); | |
| 2728 } else if (base::EndsWith(mime_type, "javascript", | |
|
Deprecated (see juliatuttle)
2016/03/23 19:28:48
Did you want to check for ecmascript as well?
jkarlin
2016/03/24 11:09:00
Done.
| |
| 2729 base::CompareCase::SENSITIVE)) { | |
| 2730 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.JavaScript"), | |
| 2731 transaction_pattern_, PATTERN_MAX); | |
| 2732 } else if (mime_type.find("font") != std::string::npos) { | |
| 2733 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Font"), | |
| 2734 transaction_pattern_, PATTERN_MAX); | |
| 2735 } | |
| 2736 } | |
| 2737 | |
| 2707 UMA_HISTOGRAM_ENUMERATION( | 2738 UMA_HISTOGRAM_ENUMERATION( |
| 2708 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); | 2739 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); |
| 2709 if (transaction_pattern_ == PATTERN_NOT_COVERED) | 2740 if (transaction_pattern_ == PATTERN_NOT_COVERED) |
| 2710 return; | 2741 return; |
| 2711 DCHECK(!range_requested_); | 2742 DCHECK(!range_requested_); |
| 2712 DCHECK(!first_cache_access_since_.is_null()); | 2743 DCHECK(!first_cache_access_since_.is_null()); |
| 2713 | 2744 |
| 2714 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; | 2745 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; |
| 2715 | 2746 |
| 2716 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); | 2747 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2774 default: | 2805 default: |
| 2775 NOTREACHED(); | 2806 NOTREACHED(); |
| 2776 } | 2807 } |
| 2777 } | 2808 } |
| 2778 | 2809 |
| 2779 void HttpCache::Transaction::OnIOComplete(int result) { | 2810 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2780 DoLoop(result); | 2811 DoLoop(result); |
| 2781 } | 2812 } |
| 2782 | 2813 |
| 2783 } // namespace net | 2814 } // namespace net |
| OLD | NEW |