| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), | 339 new Fetcher(request_context_.get(), resource_urls_to_fetch_.front(), |
| 340 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, | 340 base::Bind(&PrecacheFetcher::OnResourceFetchComplete, |
| 341 base::Unretained(this)), | 341 base::Unretained(this)), |
| 342 true /* is_resource_request */, max_bytes))); | 342 true /* is_resource_request */, max_bytes))); |
| 343 | 343 |
| 344 resource_urls_to_fetch_.pop_front(); | 344 resource_urls_to_fetch_.pop_front(); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 void PrecacheFetcher::StartNextManifestFetch() { | 348 void PrecacheFetcher::StartNextManifestFetch() { |
| 349 if (manifest_urls_to_fetch_.empty()) | 349 if (manifest_urls_to_fetch_.empty() || !pool_.IsAvailable()) |
| 350 return; | 350 return; |
| 351 | 351 |
| 352 // We only fetch one manifest at a time to keep the size of | 352 // We only fetch one manifest at a time to keep the size of |
| 353 // resource_urls_to_fetch_ as small as possible. | 353 // resource_urls_to_fetch_ as small as possible. |
| 354 DCHECK(pool_.IsAvailable()) | |
| 355 << "There are no available parallel requests to fetch the next manifest. " | |
| 356 "Did you forget to call Delete?"; | |
| 357 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); | 354 VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front(); |
| 358 pool_.Add(base::WrapUnique(new Fetcher( | 355 pool_.Add(base::WrapUnique(new Fetcher( |
| 359 request_context_.get(), manifest_urls_to_fetch_.front(), | 356 request_context_.get(), manifest_urls_to_fetch_.front(), |
| 360 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, | 357 base::Bind(&PrecacheFetcher::OnManifestFetchComplete, |
| 361 base::Unretained(this)), | 358 base::Unretained(this)), |
| 362 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); | 359 false /* is_resource_request */, std::numeric_limits<int32_t>::max()))); |
| 363 | 360 |
| 364 manifest_urls_to_fetch_.pop_front(); | 361 manifest_urls_to_fetch_.pop_front(); |
| 365 } | 362 } |
| 366 | 363 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 StartNextFetch(); | 451 StartNextFetch(); |
| 455 } | 452 } |
| 456 | 453 |
| 457 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 454 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 458 int64_t network_response_bytes) { | 455 int64_t network_response_bytes) { |
| 459 total_response_bytes_ += response_bytes; | 456 total_response_bytes_ += response_bytes; |
| 460 network_response_bytes_ += network_response_bytes; | 457 network_response_bytes_ += network_response_bytes; |
| 461 } | 458 } |
| 462 | 459 |
| 463 } // namespace precache | 460 } // namespace precache |
| OLD | NEW |