| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), | 409 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), |
| 410 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, | 410 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, |
| 411 base::Unretained(this)), | 411 base::Unretained(this)), |
| 412 true /* is_resource_request */, max_bytes))); | 412 true /* is_resource_request */, max_bytes))); |
| 413 | 413 |
| 414 resource_urls_to_fetch_.pop_front(); | 414 resource_urls_to_fetch_.pop_front(); |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 void PrecacheFetcher::StartNextManifestFetch() { | 418 void PrecacheFetcher::StartNextManifestFetch() { |
| 419 if (manifest_urls_to_fetch_.empty()) | 419 if (manifest_urls_to_fetch_.empty() || !pool_.IsAvailable()) |
| 420 return; | 420 return; |
| 421 | 421 |
| 422 // We only fetch one manifest at a time to keep the size of | 422 // We only fetch one manifest at a time to keep the size of |
| 423 // resource_urls_to_fetch_ as small as possible. | 423 // resource_urls_to_fetch_ as small as possible. |
| 424 DCHECK(pool_.IsAvailable()) | |
| 425 << "There are no available parallel requests to fetch the next manifest. " | |
| 426 "Did you forget to call Delete?"; | |
| 427 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); | 424 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); |
| 428 pool_.Add(base::WrapUnique(new Fetcher( | 425 pool_.Add(base::WrapUnique(new Fetcher( |
| 429 request_context_.get(), manifest_urls_to_fetch_.front(), | 426 request_context_.get(), manifest_urls_to_fetch_.front(), |
| 430 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, | 427 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, |
| 431 base::Unretained(this)), | 428 base::Unretained(this)), |
| 432 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); | 429 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); |
| 433 | 430 |
| 434 manifest_urls_to_fetch_.pop_front(); | 431 manifest_urls_to_fetch_.pop_front(); |
| 435 } | 432 } |
| 436 | 433 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 558 |
| 562 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 559 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 563 int64_t network_response_bytes) { | 560 int64_t network_response_bytes) { |
| 564 unfinished_work_->set_total_bytes( | 561 unfinished_work_->set_total_bytes( |
| 565 unfinished_work_->total_bytes() + response_bytes); | 562 unfinished_work_->total_bytes() + response_bytes); |
| 566 unfinished_work_->set_network_bytes( | 563 unfinished_work_->set_network_bytes( |
| 567 unfinished_work_->network_bytes() + network_response_bytes); | 564 unfinished_work_->network_bytes() + network_response_bytes); |
| 568 } | 565 } |
| 569 | 566 |
| 570 } // namespace precache | 567 } // namespace precache |
| OLD | NEW |