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

Side by Side Diff: components/precache/core/precache_fetcher.cc

Issue 1481143002: Added HttpUtils::HasValidators and HttpResponse::HasValidators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarified the documentation Created 4 years, 9 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 | « no previous file | components/precache/core/precache_fetcher_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/precache/core/precache_fetcher.h" 5 #include "components/precache/core/precache_fetcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // they expire from the cache minutes after we request them. 184 // they expire from the cache minutes after we request them.
185 url_fetcher_network_->SetLoadFlags(kNoTracking); 185 url_fetcher_network_->SetLoadFlags(kNoTracking);
186 } 186 }
187 url_fetcher_network_->Start(); 187 url_fetcher_network_->Start();
188 } 188 }
189 189
190 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) { 190 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) {
191 if (fetch_stage_ == FetchStage::CACHE && 191 if (fetch_stage_ == FetchStage::CACHE &&
192 (source->GetStatus().error() == net::ERR_CACHE_MISS || 192 (source->GetStatus().error() == net::ERR_CACHE_MISS ||
193 (source->GetResponseHeaders() && 193 (source->GetResponseHeaders() &&
194 source->GetResponseHeaders()->HasStrongValidators()))) { 194 source->GetResponseHeaders()->HasValidators()))) {
195 // If the resource was not found in the cache, request it from the 195 // If the resource was not found in the cache, request it from the
196 // network. 196 // network.
197 // 197 //
198 // If the resource was found in the cache, but contains validators, 198 // If the resource was found in the cache, but contains validators,
199 // request a refresh. The presence of validators increases the chance that 199 // request a refresh. The presence of validators increases the chance that
200 // we get a 304 response rather than a full one, thus allowing us to 200 // we get a 304 response rather than a full one, thus allowing us to
201 // refresh the cache with minimal network load. 201 // refresh the cache with minimal network load.
202 // 202 //
203 // TODO(twifkak): Add support for weak validators, which should be just as 203 // TODO(twifkak): Add support for weak validators, which should be just as
204 // likely a guarantee that the response will be a 304. 204 // likely a guarantee that the response will be a 304.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 StartNextFetch(); 371 StartNextFetch();
372 } 372 }
373 373
374 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { 374 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) {
375 // The resource has already been put in the cache during the fetch process, so 375 // The resource has already been put in the cache during the fetch process, so
376 // nothing more needs to be done for the resource. 376 // nothing more needs to be done for the resource.
377 StartNextFetch(); 377 StartNextFetch();
378 } 378 }
379 379
380 } // namespace precache 380 } // namespace precache
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698