Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 2398613002: [HttpCache] LOAD_ONLY_FROM_CACHE should not imply LOAD_PREFERRING_CACHE (Closed)
Patch Set: Nit Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 return true; 1977 return true;
1978 } 1978 }
1979 1979
1980 int HttpCache::Transaction::BeginCacheRead() { 1980 int HttpCache::Transaction::BeginCacheRead() {
1981 // We don't support any combination of LOAD_ONLY_FROM_CACHE and byte ranges. 1981 // We don't support any combination of LOAD_ONLY_FROM_CACHE and byte ranges.
1982 if (response_.headers->response_code() == 206 || partial_) { 1982 if (response_.headers->response_code() == 206 || partial_) {
1983 NOTREACHED(); 1983 NOTREACHED();
1984 return ERR_CACHE_MISS; 1984 return ERR_CACHE_MISS;
1985 } 1985 }
1986 1986
1987 if (request_->method == "HEAD")
1988 FixHeadersForHead();
1989
1990 // We don't have the whole resource. 1987 // We don't have the whole resource.
1991 if (truncated_) 1988 if (truncated_)
1992 return ERR_CACHE_MISS; 1989 return ERR_CACHE_MISS;
1993 1990
1991 // Verify that the response is still valid unless LOAD_SKIP_CACHE_VALIDATION
1992 // is set.
1993 if (!(effective_load_flags_ & LOAD_SKIP_CACHE_VALIDATION) &&
1994 RequiresValidation() != VALIDATION_NONE)
gavinp 2016/10/07 16:45:09 Nit: Doesn't this need a { per our style guide?
jkarlin 2016/10/13 15:33:58 Done.
1995 return ERR_CACHE_MISS;
1996
1997 if (request_->method == "HEAD")
1998 FixHeadersForHead();
1999
1994 if (entry_->disk_entry->GetDataSize(kMetadataIndex)) 2000 if (entry_->disk_entry->GetDataSize(kMetadataIndex))
1995 next_state_ = STATE_CACHE_READ_METADATA; 2001 next_state_ = STATE_CACHE_READ_METADATA;
1996 2002
1997 return OK; 2003 return OK;
1998 } 2004 }
1999 2005
2000 int HttpCache::Transaction::BeginCacheValidation() { 2006 int HttpCache::Transaction::BeginCacheValidation() {
2001 DCHECK_EQ(mode_, READ_WRITE); 2007 DCHECK_EQ(mode_, READ_WRITE);
2002 2008
2003 ValidationType required_validation = RequiresValidation(); 2009 ValidationType required_validation = RequiresValidation();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 // - watch out for cached responses that depend on authentication 2203 // - watch out for cached responses that depend on authentication
2198 2204
2199 if (response_.vary_data.is_valid() && 2205 if (response_.vary_data.is_valid() &&
2200 !response_.vary_data.MatchesRequest(*request_, 2206 !response_.vary_data.MatchesRequest(*request_,
2201 *response_.headers.get())) { 2207 *response_.headers.get())) {
2202 vary_mismatch_ = true; 2208 vary_mismatch_ = true;
2203 validation_cause_ = VALIDATION_CAUSE_VARY_MISMATCH; 2209 validation_cause_ = VALIDATION_CAUSE_VARY_MISMATCH;
2204 return VALIDATION_SYNCHRONOUS; 2210 return VALIDATION_SYNCHRONOUS;
2205 } 2211 }
2206 2212
2207 if (effective_load_flags_ & LOAD_PREFERRING_CACHE) 2213 if (effective_load_flags_ & LOAD_SKIP_CACHE_VALIDATION)
2208 return VALIDATION_NONE; 2214 return VALIDATION_NONE;
2209 2215
2210 if (response_.unused_since_prefetch && 2216 if (response_.unused_since_prefetch &&
2211 !(effective_load_flags_ & LOAD_PREFETCH) && 2217 !(effective_load_flags_ & LOAD_PREFETCH) &&
2212 response_.headers->GetCurrentAge( 2218 response_.headers->GetCurrentAge(
2213 response_.request_time, response_.response_time, 2219 response_.request_time, response_.response_time,
2214 cache_->clock_->Now()) < TimeDelta::FromMinutes(kPrefetchReuseMins)) { 2220 cache_->clock_->Now()) < TimeDelta::FromMinutes(kPrefetchReuseMins)) {
2215 // The first use of a resource after prefetch within a short window skips 2221 // The first use of a resource after prefetch within a short window skips
2216 // validation. 2222 // validation.
2217 return VALIDATION_NONE; 2223 return VALIDATION_NONE;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 default: 2945 default:
2940 NOTREACHED(); 2946 NOTREACHED();
2941 } 2947 }
2942 } 2948 }
2943 2949
2944 void HttpCache::Transaction::OnIOComplete(int result) { 2950 void HttpCache::Transaction::OnIOComplete(int result) {
2945 DoLoop(result); 2951 DoLoop(result);
2946 } 2952 }
2947 2953
2948 } // namespace net 2954 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698