Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 if (resource.has_url()) | 352 if (resource.has_url()) |
| 353 resource_urls_to_fetch_.push_back(GURL(resource.url())); | 353 resource_urls_to_fetch_.push_back(GURL(resource.url())); |
| 354 } | 354 } |
| 355 unfinished_work_ = std::move(unfinished_work); | 355 unfinished_work_ = std::move(unfinished_work); |
| 356 } | 356 } |
| 357 | 357 |
| 358 PrecacheFetcher::~PrecacheFetcher() { | 358 PrecacheFetcher::~PrecacheFetcher() { |
| 359 } | 359 } |
| 360 | 360 |
| 361 std::unique_ptr<PrecacheUnfinishedWork> PrecacheFetcher::CancelPrecaching() { | 361 std::unique_ptr<PrecacheUnfinishedWork> PrecacheFetcher::CancelPrecaching() { |
| 362 if (!unfinished_work_) | |
| 363 return nullptr; | |
|
Raj
2016/07/08 17:57:35
CancelPrecaching() could get called multiple times
sclittle
2016/07/11 18:16:51
Could you add this comment to the code too?
| |
| 364 | |
| 362 unfinished_work_->clear_manifest(); | 365 unfinished_work_->clear_manifest(); |
| 363 unfinished_work_->clear_resource(); | 366 unfinished_work_->clear_resource(); |
| 364 for (const auto& manifest : manifest_urls_to_fetch_) | 367 for (const auto& manifest : manifest_urls_to_fetch_) |
| 365 unfinished_work_->add_manifest()->set_url(manifest.spec()); | 368 unfinished_work_->add_manifest()->set_url(manifest.spec()); |
| 366 for (const auto& resource : resource_urls_to_fetch_) | 369 for (const auto& resource : resource_urls_to_fetch_) |
| 367 unfinished_work_->add_resource()->set_url(resource.spec()); | 370 unfinished_work_->add_resource()->set_url(resource.spec()); |
| 368 for (const auto& it : pool_.elements()) { | 371 for (const auto& it : pool_.elements()) { |
| 369 const Fetcher* fetcher = it.first; | 372 const Fetcher* fetcher = it.first; |
| 370 if (fetcher->is_resource_request()) | 373 if (fetcher->is_resource_request()) |
| 371 unfinished_work_->add_resource()->set_url(fetcher->url().spec()); | 374 unfinished_work_->add_resource()->set_url(fetcher->url().spec()); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 | 570 |
| 568 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 571 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 569 int64_t network_response_bytes) { | 572 int64_t network_response_bytes) { |
| 570 unfinished_work_->set_total_bytes( | 573 unfinished_work_->set_total_bytes( |
| 571 unfinished_work_->total_bytes() + response_bytes); | 574 unfinished_work_->total_bytes() + response_bytes); |
| 572 unfinished_work_->set_network_bytes( | 575 unfinished_work_->set_network_bytes( |
| 573 unfinished_work_->network_bytes() + network_response_bytes); | 576 unfinished_work_->network_bytes() + network_response_bytes); |
| 574 } | 577 } |
| 575 | 578 |
| 576 } // namespace precache | 579 } // namespace precache |
| OLD | NEW |