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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 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
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 <vector> 9 #include <vector>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
16 #include "components/precache/core/precache_switches.h" 17 #include "components/precache/core/precache_switches.h"
17 #include "components/precache/core/proto/precache.pb.h" 18 #include "components/precache/core/proto/precache.pb.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 PrecacheFetcher::Fetcher::~Fetcher() {} 157 PrecacheFetcher::Fetcher::~Fetcher() {}
157 158
158 void PrecacheFetcher::Fetcher::LoadFromCache() { 159 void PrecacheFetcher::Fetcher::LoadFromCache() {
159 fetch_stage_ = FetchStage::CACHE; 160 fetch_stage_ = FetchStage::CACHE;
160 url_fetcher_cache_ = URLFetcher::Create(url_, URLFetcher::GET, this); 161 url_fetcher_cache_ = URLFetcher::Create(url_, URLFetcher::GET, this);
161 url_fetcher_cache_->SetRequestContext(request_context_); 162 url_fetcher_cache_->SetRequestContext(request_context_);
162 url_fetcher_cache_->SetLoadFlags(net::LOAD_ONLY_FROM_CACHE | kNoTracking); 163 url_fetcher_cache_->SetLoadFlags(net::LOAD_ONLY_FROM_CACHE | kNoTracking);
163 scoped_ptr<URLFetcherNullWriter> null_writer(new URLFetcherNullWriter); 164 scoped_ptr<URLFetcherNullWriter> null_writer(new URLFetcherNullWriter);
164 url_fetcher_cache_->SaveResponseWithWriter(null_writer.Pass()); 165 url_fetcher_cache_->SaveResponseWithWriter(std::move(null_writer));
165 url_fetcher_cache_->Start(); 166 url_fetcher_cache_->Start();
166 } 167 }
167 168
168 void PrecacheFetcher::Fetcher::LoadFromNetwork() { 169 void PrecacheFetcher::Fetcher::LoadFromNetwork() {
169 fetch_stage_ = FetchStage::NETWORK; 170 fetch_stage_ = FetchStage::NETWORK;
170 url_fetcher_network_ = URLFetcher::Create(url_, URLFetcher::GET, this); 171 url_fetcher_network_ = URLFetcher::Create(url_, URLFetcher::GET, this);
171 url_fetcher_network_->SetRequestContext(request_context_); 172 url_fetcher_network_->SetRequestContext(request_context_);
172 if (is_resource_request_) { 173 if (is_resource_request_) {
173 // LOAD_VALIDATE_CACHE allows us to refresh Date headers for resources 174 // LOAD_VALIDATE_CACHE allows us to refresh Date headers for resources
174 // already in the cache. The Date headers are updated from 304s as well as 175 // already in the cache. The Date headers are updated from 304s as well as
175 // 200s. 176 // 200s.
176 url_fetcher_network_->SetLoadFlags(net::LOAD_VALIDATE_CACHE | kNoTracking); 177 url_fetcher_network_->SetLoadFlags(net::LOAD_VALIDATE_CACHE | kNoTracking);
177 // We don't need a copy of the response body for resource requests. The 178 // We don't need a copy of the response body for resource requests. The
178 // request is issued only to populate the browser cache. 179 // request is issued only to populate the browser cache.
179 scoped_ptr<URLFetcherNullWriter> null_writer(new URLFetcherNullWriter); 180 scoped_ptr<URLFetcherNullWriter> null_writer(new URLFetcherNullWriter);
180 url_fetcher_network_->SaveResponseWithWriter(null_writer.Pass()); 181 url_fetcher_network_->SaveResponseWithWriter(std::move(null_writer));
181 } else { 182 } else {
182 // Config and manifest requests do not need to be revalidated. It's okay if 183 // Config and manifest requests do not need to be revalidated. It's okay if
183 // they expire from the cache minutes after we request them. 184 // they expire from the cache minutes after we request them.
184 url_fetcher_network_->SetLoadFlags(kNoTracking); 185 url_fetcher_network_->SetLoadFlags(kNoTracking);
185 } 186 }
186 url_fetcher_network_->Start(); 187 url_fetcher_network_->Start();
187 } 188 }
188 189
189 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) { 190 void PrecacheFetcher::Fetcher::OnURLFetchComplete(const URLFetcher* source) {
190 if (fetch_stage_ == FetchStage::CACHE && 191 if (fetch_stage_ == FetchStage::CACHE &&
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 StartNextFetch(); 371 StartNextFetch();
371 } 372 }
372 373
373 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { 374 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) {
374 // 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
375 // nothing more needs to be done for the resource. 376 // nothing more needs to be done for the resource.
376 StartNextFetch(); 377 StartNextFetch();
377 } 378 }
378 379
379 } // namespace precache 380 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/content/precache_manager_unittest.cc ('k') | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698