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 | |
|
Deprecated (see juliatuttle)
2016/03/22 15:12:47
Have you thought about examining the content-type
jkarlin
2016/03/23 14:54:57
Yes, that's better. Thanks!
| |
| 2708 std::string request_path = request_->url.path(); | |
| 2709 if (base::EndsWith(request_path, ".js", | |
| 2710 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 2711 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.JavaScript", | |
| 2712 transaction_pattern_, PATTERN_MAX); | |
| 2713 } else if (base::EndsWith(request_path, ".css", | |
| 2714 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 2715 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.CSS", transaction_pattern_, | |
| 2716 PATTERN_MAX); | |
| 2717 } else if (base::EndsWith(request_path, ".html", | |
| 2718 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 2719 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.HTML", transaction_pattern_, | |
| 2720 PATTERN_MAX); | |
| 2721 } else if (base::EndsWith(request_path, ".jpg", | |
| 2722 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 2723 // .jpg doesn't cover all image types, but this should provide a rough idea | |
| 2724 // of the cache patterns of images. | |
| 2725 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.JPG", transaction_pattern_, | |
| 2726 PATTERN_MAX); | |
| 2727 } | |
| 2707 UMA_HISTOGRAM_ENUMERATION( | 2728 UMA_HISTOGRAM_ENUMERATION( |
| 2708 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); | 2729 "HttpCache.Pattern", transaction_pattern_, PATTERN_MAX); |
| 2709 if (transaction_pattern_ == PATTERN_NOT_COVERED) | 2730 if (transaction_pattern_ == PATTERN_NOT_COVERED) |
| 2710 return; | 2731 return; |
| 2711 DCHECK(!range_requested_); | 2732 DCHECK(!range_requested_); |
| 2712 DCHECK(!first_cache_access_since_.is_null()); | 2733 DCHECK(!first_cache_access_since_.is_null()); |
| 2713 | 2734 |
| 2714 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; | 2735 TimeDelta total_time = base::TimeTicks::Now() - first_cache_access_since_; |
| 2715 | 2736 |
| 2716 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); | 2737 UMA_HISTOGRAM_TIMES("HttpCache.AccessToDone", total_time); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2774 default: | 2795 default: |
| 2775 NOTREACHED(); | 2796 NOTREACHED(); |
| 2776 } | 2797 } |
| 2777 } | 2798 } |
| 2778 | 2799 |
| 2779 void HttpCache::Transaction::OnIOComplete(int result) { | 2800 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2780 DoLoop(result); | 2801 DoLoop(result); |
| 2781 } | 2802 } |
| 2782 | 2803 |
| 2783 } // namespace net | 2804 } // namespace net |
| OLD | NEW |