Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Side by Side Diff: components/precache/core/precache_fetcher.cc

Issue 2037903002: Precache manifest should not be added to fetcher pool which is full (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698