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" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2112 return OK; | 2112 return OK; |
2113 } | 2113 } |
2114 | 2114 |
2115 int HttpCache::Transaction::BeginCacheValidation() { | 2115 int HttpCache::Transaction::BeginCacheValidation() { |
2116 DCHECK(mode_ == READ_WRITE); | 2116 DCHECK(mode_ == READ_WRITE); |
2117 | 2117 |
2118 ValidationType required_validation = RequiresValidation(); | 2118 ValidationType required_validation = RequiresValidation(); |
2119 | 2119 |
2120 bool skip_validation = (required_validation == VALIDATION_NONE); | 2120 bool skip_validation = (required_validation == VALIDATION_NONE); |
2121 | 2121 |
2122 if ((effective_load_flags_ & LOAD_SUPPORT_ASYNC_REVALIDATION) && | |
2123 required_validation == VALIDATION_ASYNCHRONOUS) { | |
2124 DCHECK_EQ("GET", request_->method); | |
2125 skip_validation = true; | |
2126 response_.async_revalidation_required = true; | |
2127 } | |
2128 | |
2122 if (request_->method == "HEAD" && | 2129 if (request_->method == "HEAD" && |
2123 (truncated_ || response_.headers->response_code() == 206)) { | 2130 (truncated_ || response_.headers->response_code() == 206)) { |
2124 DCHECK(!partial_); | 2131 DCHECK(!partial_); |
2125 if (skip_validation) | 2132 if (skip_validation) |
2126 return SetupEntryForRead(); | 2133 return SetupEntryForRead(); |
2127 | 2134 |
2128 // Bail out! | 2135 // Bail out! |
2129 next_state_ = STATE_SEND_REQUEST; | 2136 next_state_ = STATE_SEND_REQUEST; |
2130 mode_ = NONE; | 2137 mode_ = NONE; |
2131 return OK; | 2138 return OK; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2243 } | 2250 } |
2244 } | 2251 } |
2245 | 2252 |
2246 // TODO(ricea): This calculation is expensive to perform just to collect | 2253 // TODO(ricea): This calculation is expensive to perform just to collect |
2247 // statistics. Either remove it or use the result, depending on the result of | 2254 // statistics. Either remove it or use the result, depending on the result of |
2248 // the experiment. | 2255 // the experiment. |
2249 ExternallyConditionalizedType type = | 2256 ExternallyConditionalizedType type = |
2250 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; | 2257 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; |
2251 if (mode_ == NONE) | 2258 if (mode_ == NONE) |
2252 type = EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS; | 2259 type = EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS; |
2253 else if (RequiresValidation()) | 2260 else if (RequiresValidation()) |
tyoshino (SeeGerritForStatus)
2015/06/15 09:40:02
RequiresValidation() returns an enum. It's not str
Adam Rice
2015/06/15 10:17:41
Done. I should probably remove the histogram altog
| |
2254 type = EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION; | 2261 type = EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION; |
2255 | 2262 |
2256 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed. | 2263 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed. |
2257 // TODO(ricea): Either remove this histogram or make it permanent by M40. | 2264 // TODO(ricea): Either remove this histogram or make it permanent by M40. |
2258 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized", | 2265 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized", |
2259 type, | 2266 type, |
2260 EXTERNALLY_CONDITIONALIZED_MAX); | 2267 EXTERNALLY_CONDITIONALIZED_MAX); |
2261 | 2268 |
2262 next_state_ = STATE_SEND_REQUEST; | 2269 next_state_ = STATE_SEND_REQUEST; |
2263 return OK; | 2270 return OK; |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2938 default: | 2945 default: |
2939 NOTREACHED(); | 2946 NOTREACHED(); |
2940 } | 2947 } |
2941 } | 2948 } |
2942 | 2949 |
2943 void HttpCache::Transaction::OnIOComplete(int result) { | 2950 void HttpCache::Transaction::OnIOComplete(int result) { |
2944 DoLoop(result); | 2951 DoLoop(result); |
2945 } | 2952 } |
2946 | 2953 |
2947 } // namespace net | 2954 } // namespace net |
OLD | NEW |