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

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

Issue 2614403003: Add revalidation_only option to precache config. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.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 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // network_url_fetcher() will return nullptr. 292 // network_url_fetcher() will return nullptr.
293 class PrecacheFetcher::Fetcher : public net::URLFetcherDelegate { 293 class PrecacheFetcher::Fetcher : public net::URLFetcherDelegate {
294 public: 294 public:
295 // Construct a new Fetcher. This will create and start a new URLFetcher for 295 // Construct a new Fetcher. This will create and start a new URLFetcher for
296 // the specified URL using the specified request context. 296 // the specified URL using the specified request context.
297 Fetcher(net::URLRequestContextGetter* request_context, 297 Fetcher(net::URLRequestContextGetter* request_context,
298 const GURL& url, 298 const GURL& url,
299 const std::string& referrer, 299 const std::string& referrer,
300 const base::Callback<void(const Fetcher&)>& callback, 300 const base::Callback<void(const Fetcher&)>& callback,
301 bool is_resource_request, 301 bool is_resource_request,
302 size_t max_bytes); 302 size_t max_bytes,
303 bool revalidation_only);
bengr 2017/01/11 20:08:46 Please add a description of parameters to the meth
twifkak 2017/01/11 20:40:15 Done.
303 ~Fetcher() override; 304 ~Fetcher() override;
304 void OnURLFetchDownloadProgress(const net::URLFetcher* source, 305 void OnURLFetchDownloadProgress(const net::URLFetcher* source,
305 int64_t current, 306 int64_t current,
306 int64_t total, 307 int64_t total,
307 int64_t current_network_bytes) override; 308 int64_t current_network_bytes) override;
308 void OnURLFetchComplete(const net::URLFetcher* source) override; 309 void OnURLFetchComplete(const net::URLFetcher* source) override;
309 int64_t response_bytes() const { return response_bytes_; } 310 int64_t response_bytes() const { return response_bytes_; }
310 int64_t network_response_bytes() const { return network_response_bytes_; } 311 int64_t network_response_bytes() const { return network_response_bytes_; }
311 const net::URLFetcher* network_url_fetcher() const { 312 const net::URLFetcher* network_url_fetcher() const {
312 return network_url_fetcher_.get(); 313 return network_url_fetcher_.get();
313 } 314 }
314 const GURL& url() const { return url_; } 315 const GURL& url() const { return url_; }
315 const std::string& referrer() const { return referrer_; } 316 const std::string& referrer() const { return referrer_; }
316 bool is_resource_request() const { return is_resource_request_; } 317 bool is_resource_request() const { return is_resource_request_; }
317 bool was_cached() const { return was_cached_; } 318 bool was_cached() const { return was_cached_; }
318 319
319 private: 320 private:
320 enum class FetchStage { CACHE, NETWORK }; 321 enum class FetchStage { CACHE, NETWORK };
321 322
322 void LoadFromCache(); 323 void LoadFromCache();
323 void LoadFromNetwork(); 324 void LoadFromNetwork();
324 325
325 net::URLRequestContextGetter* const request_context_; 326 net::URLRequestContextGetter* const request_context_;
326 const GURL url_; 327 const GURL url_;
327 const std::string referrer_; 328 const std::string referrer_;
328 const base::Callback<void(const Fetcher&)> callback_; 329 const base::Callback<void(const Fetcher&)> callback_;
329 const bool is_resource_request_; 330 const bool is_resource_request_;
330 const size_t max_bytes_; 331 const size_t max_bytes_;
332 const bool revalidation_only_;
bengr 2017/01/11 20:08:46 is_resource_request_, max_bytes_, and revalidation
twifkak 2017/01/11 20:40:15 OK, added parameter comments to the constructor, a
331 333
332 FetchStage fetch_stage_; 334 FetchStage fetch_stage_;
333 // The cache_url_fetcher_ is kept alive until Fetcher destruction for testing. 335 // The cache_url_fetcher_ is kept alive until Fetcher destruction for testing.
334 std::unique_ptr<net::URLFetcher> cache_url_fetcher_; 336 std::unique_ptr<net::URLFetcher> cache_url_fetcher_;
335 std::unique_ptr<net::URLFetcher> network_url_fetcher_; 337 std::unique_ptr<net::URLFetcher> network_url_fetcher_;
336 int64_t response_bytes_; 338 int64_t response_bytes_;
337 int64_t network_response_bytes_; 339 int64_t network_response_bytes_;
338 bool was_cached_; 340 bool was_cached_;
339 341
340 DISALLOW_COPY_AND_ASSIGN(Fetcher); 342 DISALLOW_COPY_AND_ASSIGN(Fetcher);
341 }; 343 };
342 344
343 } // namespace precache 345 } // namespace precache
344 346
345 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 347 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698