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

Unified 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: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: components/precache/core/precache_fetcher.cc
diff --git a/components/precache/core/precache_fetcher.cc b/components/precache/core/precache_fetcher.cc
index cfcc3dcffb43c4c109cc7dfa3d5a3b334e24ee79..16effb64d34e3a866d075fe49b50748012a9b219 100644
--- a/components/precache/core/precache_fetcher.cc
+++ b/components/precache/core/precache_fetcher.cc
@@ -46,11 +46,15 @@ const int kNoTracking =
net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SEND_AUTH_DATA;
-namespace {
-
// The maximum number of URLFetcher requests that can be on flight in parallel.
const int kMaxParallelFetches = 10;
+int GetDefaultMaxParallelFetches() {
+ return kMaxParallelFetches;
+}
+
+namespace {
+
// The maximum for the Precache.Fetch.ResponseBytes.* histograms. We set this to
// a number we expect to be in the 99th percentile for the histogram, give or
// take.
@@ -327,7 +331,7 @@ PrecacheFetcher::PrecacheFetcher(
config_url_(config_url),
manifest_url_prefix_(manifest_url_prefix),
precache_delegate_(precache_delegate),
- pool_(kMaxParallelFetches),
+ pool_(GetDefaultMaxParallelFetches()),
experiment_id_(experiment_id) {
DCHECK(request_context_.get()); // Request context must be non-NULL.
DCHECK(precache_delegate_); // Precache delegate must be non-NULL.
@@ -416,14 +420,11 @@ void PrecacheFetcher::StartNextResourceFetch() {
}
void PrecacheFetcher::StartNextManifestFetch() {
- if (manifest_urls_to_fetch_.empty())
+ if (manifest_urls_to_fetch_.empty() || !pool_.IsAvailable())
return;
// We only fetch one manifest at a time to keep the size of
// resource_urls_to_fetch_ as small as possible.
- DCHECK(pool_.IsAvailable())
- << "There are no available parallel requests to fetch the next manifest. "
- "Did you forget to call Delete?";
VLOG(3) << "Fetching " << manifest_urls_to_fetch_.front();
pool_.Add(base::WrapUnique(new Fetcher(
request_context_.get(), manifest_urls_to_fetch_.front(),

Powered by Google App Engine
This is Rietveld 408576698