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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 void RecordNoStoreHeaderHistogram(int load_flags, | 232 void RecordNoStoreHeaderHistogram(int load_flags, |
233 const net::HttpResponseInfo* response) { | 233 const net::HttpResponseInfo* response) { |
234 if (load_flags & net::LOAD_MAIN_FRAME) { | 234 if (load_flags & net::LOAD_MAIN_FRAME) { |
235 UMA_HISTOGRAM_BOOLEAN( | 235 UMA_HISTOGRAM_BOOLEAN( |
236 "Net.MainFrameNoStore", | 236 "Net.MainFrameNoStore", |
237 response->headers->HasHeaderValue("cache-control", "no-store")); | 237 response->headers->HasHeaderValue("cache-control", "no-store")); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
| 241 enum ExternallyConditionalizedType { |
| 242 EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION, |
| 243 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE, |
| 244 EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS, |
| 245 EXTERNALLY_CONDITIONALIZED_MAX |
| 246 }; |
| 247 |
241 } // namespace | 248 } // namespace |
242 | 249 |
243 namespace net { | 250 namespace net { |
244 | 251 |
245 struct HeaderNameAndValue { | 252 struct HeaderNameAndValue { |
246 const char* name; | 253 const char* name; |
247 const char* value; | 254 const char* value; |
248 }; | 255 }; |
249 | 256 |
250 // If the request includes one of these request headers, then avoid caching | 257 // If the request includes one of these request headers, then avoid caching |
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 | 2226 |
2220 if (response_.headers->response_code() != 200 || truncated_ || | 2227 if (response_.headers->response_code() != 200 || truncated_ || |
2221 validator.empty() || validator != external_validation_.values[i]) { | 2228 validator.empty() || validator != external_validation_.values[i]) { |
2222 // The externally conditionalized request is not a validation request | 2229 // The externally conditionalized request is not a validation request |
2223 // for our existing cache entry. Proceed with caching disabled. | 2230 // for our existing cache entry. Proceed with caching disabled. |
2224 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 2231 UpdateTransactionPattern(PATTERN_NOT_COVERED); |
2225 DoneWritingToEntry(true); | 2232 DoneWritingToEntry(true); |
2226 } | 2233 } |
2227 } | 2234 } |
2228 | 2235 |
| 2236 // TODO(ricea): This calculation is expensive to perform just to collect |
| 2237 // statistics. Either remove it or use the result, depending on the result of |
| 2238 // the experiment. |
| 2239 ExternallyConditionalizedType type = |
| 2240 EXTERNALLY_CONDITIONALIZED_CACHE_USABLE; |
| 2241 if (mode_ == NONE) |
| 2242 type = EXTERNALLY_CONDITIONALIZED_MISMATCHED_VALIDATORS; |
| 2243 else if (RequiresValidation()) |
| 2244 type = EXTERNALLY_CONDITIONALIZED_CACHE_REQUIRES_VALIDATION; |
| 2245 |
| 2246 // TODO(ricea): Add CACHE_USABLE_STALE once stale-while-revalidate CL landed. |
| 2247 // TODO(ricea): Either remove this histogram or make it permanent by M40. |
| 2248 UMA_HISTOGRAM_ENUMERATION("HttpCache.ExternallyConditionalized", |
| 2249 type, |
| 2250 EXTERNALLY_CONDITIONALIZED_MAX); |
| 2251 |
2229 next_state_ = STATE_SEND_REQUEST; | 2252 next_state_ = STATE_SEND_REQUEST; |
2230 return OK; | 2253 return OK; |
2231 } | 2254 } |
2232 | 2255 |
2233 int HttpCache::Transaction::RestartNetworkRequest() { | 2256 int HttpCache::Transaction::RestartNetworkRequest() { |
2234 DCHECK(mode_ & WRITE || mode_ == NONE); | 2257 DCHECK(mode_ & WRITE || mode_ == NONE); |
2235 DCHECK(network_trans_.get()); | 2258 DCHECK(network_trans_.get()); |
2236 DCHECK_EQ(STATE_NONE, next_state_); | 2259 DCHECK_EQ(STATE_NONE, next_state_); |
2237 | 2260 |
2238 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 2261 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 default: | 2892 default: |
2870 NOTREACHED(); | 2893 NOTREACHED(); |
2871 } | 2894 } |
2872 } | 2895 } |
2873 | 2896 |
2874 void HttpCache::Transaction::OnIOComplete(int result) { | 2897 void HttpCache::Transaction::OnIOComplete(int result) { |
2875 DoLoop(result); | 2898 DoLoop(result); |
2876 } | 2899 } |
2877 | 2900 |
2878 } // namespace net | 2901 } // namespace net |
OLD | NEW |