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

Unified Diff: components/precache/content/precache_manager.cc

Issue 1961153003: Add pause/resume functionality to precache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/content/precache_manager.cc
diff --git a/components/precache/content/precache_manager.cc b/components/precache/content/precache_manager.cc
index 1d2ddb653b7742cb2d7257d3ea1aeaa37f5aba25..d69309929e47e2da18ea4caaefee6240e5468946 100644
--- a/components/precache/content/precache_manager.cc
+++ b/components/precache/content/precache_manager.cc
@@ -167,7 +167,14 @@ void PrecacheManager::CancelPrecaching() {
return;
}
is_precaching_ = false;
+ // If cancellation occurs after StartPrecaching but before OnHostsReceived,
+ // is_precaching will be true, but the precache_fetcher_ will not yet be
+ // constructed.
+ if (precache_fetcher_)
+ precache_fetcher_->Shutdown();
+}
+void PrecacheManager::OnShutdownDone() {
// Destroying the |precache_fetcher_| will cancel any fetch in progress.
precache_fetcher_.reset();
@@ -250,7 +257,6 @@ void PrecacheManager::Shutdown() {
void PrecacheManager::OnDone() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
precache_fetcher_.reset();
// Run completion callback if not null. It's null if the client is in the
@@ -278,7 +284,6 @@ void PrecacheManager::OnHostsReceived(
std::vector<std::string> hosts;
for (const auto& host_count : host_counts)
hosts.push_back(host_count.first);
-
// Start precaching.
precache_fetcher_.reset(new PrecacheFetcher(
hosts,
@@ -288,7 +293,13 @@ void PrecacheManager::OnHostsReceived(
kPrecacheFieldTrialName, kConfigURLParam)),
variations::GetVariationParamValue(
kPrecacheFieldTrialName, kManifestURLPrefixParam),
- this));
+ this,
+ precache_database_->GetWeakPtr(),
+ BrowserThread::GetMessageLoopProxyForThread( BrowserThread::DB)));
+ precache_fetcher_->Init(base::TimeDelta::FromHours(6));
+}
+
+void PrecacheManager::OnInitDone() {
sclittle 2016/05/10 00:01:26 Why is this method necessary? Couldn't PrecacheFet
bengr 2016/05/19 01:25:44 Done.
precache_fetcher_->Start();
}

Powered by Google App Engine
This is Rietveld 408576698