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 <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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |