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 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 return OK; | 2108 return OK; |
2109 } | 2109 } |
2110 | 2110 |
2111 int HttpCache::Transaction::BeginCacheValidation() { | 2111 int HttpCache::Transaction::BeginCacheValidation() { |
2112 DCHECK_EQ(mode_, READ_WRITE); | 2112 DCHECK_EQ(mode_, READ_WRITE); |
2113 | 2113 |
2114 ValidationType required_validation = RequiresValidation(); | 2114 ValidationType required_validation = RequiresValidation(); |
2115 | 2115 |
2116 bool skip_validation = (required_validation == VALIDATION_NONE); | 2116 bool skip_validation = (required_validation == VALIDATION_NONE); |
2117 | 2117 |
| 2118 if ((effective_load_flags_ & LOAD_SUPPORT_ASYNC_REVALIDATION) && |
| 2119 required_validation == VALIDATION_ASYNCHRONOUS) { |
| 2120 DCHECK_EQ(request_->method, "GET"); |
| 2121 skip_validation = true; |
| 2122 response_.async_revalidation_required = true; |
| 2123 } |
| 2124 |
2118 if (request_->method == "HEAD" && | 2125 if (request_->method == "HEAD" && |
2119 (truncated_ || response_.headers->response_code() == 206)) { | 2126 (truncated_ || response_.headers->response_code() == 206)) { |
2120 DCHECK(!partial_); | 2127 DCHECK(!partial_); |
2121 if (skip_validation) | 2128 if (skip_validation) |
2122 return SetupEntryForRead(); | 2129 return SetupEntryForRead(); |
2123 | 2130 |
2124 // Bail out! | 2131 // Bail out! |
2125 next_state_ = STATE_SEND_REQUEST; | 2132 next_state_ = STATE_SEND_REQUEST; |
2126 mode_ = NONE; | 2133 mode_ = NONE; |
2127 return OK; | 2134 return OK; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 } | 2242 } |
2236 } | 2243 } |
2237 | 2244 |
2238 // TODO(ricea): This calculation is expensive to perform just to collect | 2245 // TODO(ricea): This calculation is expensive to perform just to collect |
2239 // statistics. Either remove it or use the result, depending on the result of | 2246 // statistics. Either remove it or use the result, depending on the result of |
2240 // the experiment. | 2247 // the experiment. |
2241 ExternallyConditionalizedType type = | 2248 ExternallyConditionalizedType type = |
2242 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; | 2249 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; |
2243 if (mode_ == NONE) | 2250 if (mode_ == NONE) |
2244 type = EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS; | 2251 type = EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS; |
2245 else if (RequiresValidation()) | 2252 else if (RequiresValidation() != VALIDATION_NONE) |
2246 type = EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION; | 2253 type = EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION; |
2247 | 2254 |
2248 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed. | 2255 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed. |
2249 // TODO(ricea): Either remove this histogram or make it permanent by M40. | 2256 // TODO(ricea): Either remove this histogram or make it permanent by M40. |
2250 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized", | 2257 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized", |
2251 type, | 2258 type, |
2252 EXTERNALLY_CONDITIONALIZED_MAX); | 2259 EXTERNALLY_CONDITIONALIZED_MAX); |
2253 | 2260 |
2254 next_state_ = STATE_SEND_REQUEST; | 2261 next_state_ = STATE_SEND_REQUEST; |
2255 return OK; | 2262 return OK; |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 default: | 2925 default: |
2919 NOTREACHED(); | 2926 NOTREACHED(); |
2920 } | 2927 } |
2921 } | 2928 } |
2922 | 2929 |
2923 void HttpCache::Transaction::OnIOComplete(int result) { | 2930 void HttpCache::Transaction::OnIOComplete(int result) { |
2924 DoLoop(result); | 2931 DoLoop(result); |
2925 } | 2932 } |
2926 | 2933 |
2927 } // namespace net | 2934 } // namespace net |
OLD | NEW |