| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // From http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-21#section-6 | 58 // From http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-21#section-6 |
| 59 // a "non-error response" is one with a 2xx (Successful) or 3xx | 59 // a "non-error response" is one with a 2xx (Successful) or 3xx |
| 60 // (Redirection) status code. | 60 // (Redirection) status code. |
| 61 bool NonErrorResponse(int status_code) { | 61 bool NonErrorResponse(int status_code) { |
| 62 int status_code_range = status_code / 100; | 62 int status_code_range = status_code / 100; |
| 63 return status_code_range == 2 || status_code_range == 3; | 63 return status_code_range == 2 || status_code_range == 3; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void RecordNoStoreHeaderHistogram(int load_flags, | 66 void RecordNoStoreHeaderHistogram(int load_flags, |
| 67 const HttpResponseInfo* response) { | 67 const HttpResponseInfo* response) { |
| 68 if (load_flags & LOAD_MAIN_FRAME) { | 68 if (load_flags & LOAD_MAIN_FRAME_DEPRECATED) { |
| 69 UMA_HISTOGRAM_BOOLEAN( | 69 UMA_HISTOGRAM_BOOLEAN( |
| 70 "Net.MainFrameNoStore", | 70 "Net.MainFrameNoStore", |
| 71 response->headers->HasHeaderValue("cache-control", "no-store")); | 71 response->headers->HasHeaderValue("cache-control", "no-store")); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 enum ExternallyConditionalizedType { | 75 enum ExternallyConditionalizedType { |
| 76 EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION, | 76 EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION, |
| 77 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE, | 77 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE, |
| 78 EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS, | 78 EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS, |
| (...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 } | 2814 } |
| 2815 } | 2815 } |
| 2816 } | 2816 } |
| 2817 | 2817 |
| 2818 std::string mime_type; | 2818 std::string mime_type; |
| 2819 HttpResponseHeaders* response_headers = GetResponseInfo()->headers.get(); | 2819 HttpResponseHeaders* response_headers = GetResponseInfo()->headers.get(); |
| 2820 if (response_headers && response_headers->GetMimeType(&mime_type)) { | 2820 if (response_headers && response_headers->GetMimeType(&mime_type)) { |
| 2821 // Record the cache pattern by resource type. The type is inferred by | 2821 // Record the cache pattern by resource type. The type is inferred by |
| 2822 // response header mime type, which could be incorrect, so this is just an | 2822 // response header mime type, which could be incorrect, so this is just an |
| 2823 // estimate. | 2823 // estimate. |
| 2824 if (mime_type == "text/html" && (request_->load_flags & LOAD_MAIN_FRAME)) { | 2824 if (mime_type == "text/html" && |
| 2825 (request_->load_flags & LOAD_MAIN_FRAME_DEPRECATED)) { |
| 2825 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.MainFrameHTML", | 2826 UMA_HISTOGRAM_ENUMERATION("HttpCache.Pattern.MainFrameHTML", |
| 2826 cache_entry_status_, | 2827 cache_entry_status_, |
| 2827 CacheEntryStatus::ENTRY_MAX); | 2828 CacheEntryStatus::ENTRY_MAX); |
| 2828 if (validation_request) { | 2829 if (validation_request) { |
| 2829 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.MainFrameHTML", | 2830 UMA_HISTOGRAM_ENUMERATION("HttpCache.ValidationCause.MainFrameHTML", |
| 2830 validation_cause_, VALIDATION_CAUSE_MAX); | 2831 validation_cause_, VALIDATION_CAUSE_MAX); |
| 2831 } | 2832 } |
| 2832 if (stale_request) { | 2833 if (stale_request) { |
| 2833 UMA_HISTOGRAM_COUNTS( | 2834 UMA_HISTOGRAM_COUNTS( |
| 2834 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.MainFrameHTML", | 2835 "HttpCache.StaleEntry.FreshnessPeriodsSinceLastUsed.MainFrameHTML", |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3014 default: | 3015 default: |
| 3015 NOTREACHED(); | 3016 NOTREACHED(); |
| 3016 } | 3017 } |
| 3017 } | 3018 } |
| 3018 | 3019 |
| 3019 void HttpCache::Transaction::OnIOComplete(int result) { | 3020 void HttpCache::Transaction::OnIOComplete(int result) { |
| 3020 DoLoop(result); | 3021 DoLoop(result); |
| 3021 } | 3022 } |
| 3022 | 3023 |
| 3023 } // namespace net | 3024 } // namespace net |
| OLD | NEW |