| 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 && |
| 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", |
| 2729 base::CompareCase::SENSITIVE) || |
| 2730 base::EndsWith(mime_type, "ecmascript", |
| 2731 base::CompareCase::SENSITIVE)) { |
| 2732 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.JavaScript"), |
| 2733 transaction_pattern_, PATTERN_MAX); |
| 2734 } else if (mime_type.find("font") != std::string::npos) { |
| 2735 UMA_HISTOGRAM_ENUMERATION(std::string("HttpCache.Pattern.Font"), |
| 2736 transaction_pattern_, PATTERN_MAX); |
| 2737 } |
| 2738 } |
| 2739 |
| 2707 UMA_HISTOGRAM_ENUMERATION( | 2740 UMA_HISTOGRAM_ENUMERATION( |
| 2708 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); | 2741 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); |
| 2709 if (transaction_pattern_ == PATTERN_NOT_COVERED) | 2742 if (transaction_pattern_ == PATTERN_NOT_COVERED) |
| 2710 return; | 2743 return; |
| 2711 DCHECK(!range_requested_); | 2744 DCHECK(!range_requested_); |
| 2712 DCHECK(!first_cache_access_since_.is_null()); | 2745 DCHECK(!first_cache_access_since_.is_null()); |
| 2713 | 2746 |
| 2714 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; | 2747 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; |
| 2715 | 2748 |
| 2716 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); | 2749 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2774 default: | 2807 default: |
| 2775 NOTREACHED(); | 2808 NOTREACHED(); |
| 2776 } | 2809 } |
| 2777 } | 2810 } |
| 2778 | 2811 |
| 2779 void HttpCache::Transaction::OnIOComplete(int result) { | 2812 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2780 DoLoop(result); | 2813 DoLoop(result); |
| 2781 } | 2814 } |
| 2782 | 2815 |
| 2783 } // namespace net | 2816 } // namespace net |
| OLD | NEW |