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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), | 392 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), |
| 393 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, | 393 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, |
| 394 base::Unretained(this)), | 394 base::Unretained(this)), |
| 395 true /* is_resource_request */, max_bytes))); | 395 true /* is_resource_request */, max_bytes))); |
| 396 | 396 |
| 397 resource_urls_to_fetch_.pop_front(); | 397 resource_urls_to_fetch_.pop_front(); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 void PrecacheFetcher::StartNextManifestFetch() { | 401 void PrecacheFetcher::StartNextManifestFetch() { |
| 402 if (manifest_urls_to_fetch_.empty()) | 402 if (manifest_urls_to_fetch_.empty() || !pool_.IsAvailable()) |
|
bengr
2016/06/06 18:55:15
Could you add a test that tries to precache more r
Raj
2016/06/08 03:10:42
Done.
| |
| 403 return; | 403 return; |
| 404 | 404 |
| 405 // We only fetch one manifest at a time to keep the size of | 405 // We only fetch one manifest at a time to keep the size of |
| 406 // resource_urls_to_fetch_ as small as possible. | 406 // resource_urls_to_fetch_ as small as possible. |
| 407 DCHECK(pool_.IsAvailable()) | |
| 408 << "There are no available parallel requests to fetch the next manifest. " | |
| 409 "Did you forget to call Delete?"; | |
| 410 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); | 407 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); |
| 411 pool_.Add(base::WrapUnique(new Fetcher( | 408 pool_.Add(base::WrapUnique(new Fetcher( |
| 412 request_context_.get(), manifest_urls_to_fetch_.front(), | 409 request_context_.get(), manifest_urls_to_fetch_.front(), |
| 413 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, | 410 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, |
| 414 base::Unretained(this)), | 411 base::Unretained(this)), |
| 415 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); | 412 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); |
| 416 | 413 |
| 417 manifest_urls_to_fetch_.pop_front(); | 414 manifest_urls_to_fetch_.pop_front(); |
| 418 } | 415 } |
| 419 | 416 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 | 539 |
| 543 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 540 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 544 int64_t network_response_bytes) { | 541 int64_t network_response_bytes) { |
| 545 unfinished_work_->set_total_bytes( | 542 unfinished_work_->set_total_bytes( |
| 546 unfinished_work_->total_bytes() + response_bytes); | 543 unfinished_work_->total_bytes() + response_bytes); |
| 547 unfinished_work_->set_network_bytes( | 544 unfinished_work_->set_network_bytes( |
| 548 unfinished_work_->network_bytes() + network_response_bytes); | 545 unfinished_work_->network_bytes() + network_response_bytes); |
| 549 } | 546 } |
| 550 | 547 |
| 551 } // namespace precache | 548 } // namespace precache |
| OLD | NEW |