| OLD | NEW |
| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // they expire from the cache minutes after we request them. | 183 // they expire from the cache minutes after we request them. |
| 184 url_fetcher_network_->SetLoadFlags(kNoTracking); | 184 url_fetcher_network_->SetLoadFlags(kNoTracking); |
| 185 } | 185 } |
| 186 url_fetcher_network_->Start(); | 186 url_fetcher_network_->Start(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) { | 189 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) { |
| 190 if (fetch_stage_ == FetchStage::CACHE && | 190 if (fetch_stage_ == FetchStage::CACHE && |
| 191 (source->GetStatus().error() == net::ERR_CACHE_MISS || | 191 (source->GetStatus().error() == net::ERR_CACHE_MISS || |
| 192 (source->GetResponseHeaders() && | 192 (source->GetResponseHeaders() && |
| 193 source->GetResponseHeaders()->HasStrongValidators()))) { | 193 source->GetResponseHeaders()->HasValidators()))) { |
| 194 // If the resource was not found in the cache, request it from the | 194 // If the resource was not found in the cache, request it from the |
| 195 // network. | 195 // network. |
| 196 // | 196 // |
| 197 // If the resource was found in the cache, but contains validators, | 197 // If the resource was found in the cache, but contains validators, |
| 198 // request a refresh. The presence of validators increases the chance that | 198 // request a refresh. The presence of validators increases the chance that |
| 199 // we get a 304 response rather than a full one, thus allowing us to | 199 // we get a 304 response rather than a full one, thus allowing us to |
| 200 // refresh the cache with minimal network load. | 200 // refresh the cache with minimal network load. |
| 201 // | 201 // |
| 202 // TODO(twifkak): Add support for weak validators, which should be just as | 202 // TODO(twifkak): Add support for weak validators, which should be just as |
| 203 // likely a guarantee that the response will be a 304. | 203 // likely a guarantee that the response will be a 304. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 StartNextFetch(); | 370 StartNextFetch(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { | 373 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { |
| 374 // The resource has already been put in the cache during the fetch process, so | 374 // The resource has already been put in the cache during the fetch process, so |
| 375 // nothing more needs to be done for the resource. | 375 // nothing more needs to be done for the resource. |
| 376 StartNextFetch(); | 376 StartNextFetch(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace precache | 379 } // namespace precache |
| OLD | NEW |