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

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

Issue 2300703004: Fix precache issue with cancel and resume (Closed)
Patch Set: Created 4 years, 3 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 PrecacheFetcher::~PrecacheFetcher() { 403 PrecacheFetcher::~PrecacheFetcher() {
404 } 404 }
405 405
406 std::unique_ptr<PrecacheUnfinishedWork> PrecacheFetcher::CancelPrecaching() { 406 std::unique_ptr<PrecacheUnfinishedWork> PrecacheFetcher::CancelPrecaching() {
407 // This could get called multiple times, and it should be handled gracefully. 407 // This could get called multiple times, and it should be handled gracefully.
408 if (!unfinished_work_) 408 if (!unfinished_work_)
409 return nullptr; 409 return nullptr;
410 410
411 unfinished_work_->clear_resource(); 411 unfinished_work_->clear_resource();
412 if (top_hosts_to_fetch_.size()) { 412 if (unfinished_work_->has_config_settings()) {
sclittle 2016/09/02 18:47:56 Could you add a test for this behavior, e.g. when
Raj 2016/09/15 17:02:25 Done.
413 // If config fetch is incomplete, |top_hosts_to_fetch_| will be empty and 413 // If config fetch is incomplete, |top_hosts_to_fetch_| will be empty and
414 // top hosts should be left as is in |unfinished_work_|. 414 // top hosts should be left as is in |unfinished_work_|.
415 unfinished_work_->clear_top_host(); 415 unfinished_work_->clear_top_host();
416 for (const auto& top_host : top_hosts_to_fetch_) { 416 for (const auto& top_host : top_hosts_to_fetch_) {
417 unfinished_work_->add_top_host()->set_hostname(top_host.hostname); 417 unfinished_work_->add_top_host()->set_hostname(top_host.hostname);
418 } 418 }
419 } 419 }
420 for (const auto& resource : resources_to_fetch_) { 420 for (const auto& resource : resources_to_fetch_) {
421 auto new_resource = unfinished_work_->add_resource(); 421 auto new_resource = unfinished_work_->add_resource();
422 new_resource->set_url(resource.first.spec()); 422 new_resource->set_url(resource.first.spec());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 void PrecacheFetcher::UpdateStats(int64_t response_bytes, 693 void PrecacheFetcher::UpdateStats(int64_t response_bytes,
694 int64_t network_response_bytes) { 694 int64_t network_response_bytes) {
695 unfinished_work_->set_total_bytes( 695 unfinished_work_->set_total_bytes(
696 unfinished_work_->total_bytes() + response_bytes); 696 unfinished_work_->total_bytes() + response_bytes);
697 unfinished_work_->set_network_bytes( 697 unfinished_work_->set_network_bytes(
698 unfinished_work_->network_bytes() + network_response_bytes); 698 unfinished_work_->network_bytes() + network_response_bytes);
699 } 699 }
700 700
701 } // namespace precache 701 } // namespace precache
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_url_table.cc » ('j') | components/precache/core/precache_url_table.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698