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

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

Issue 2403193002: Precache: Optionally rank resources-to-precache globally. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/content/precache_manager.cc
diff --git a/components/precache/content/precache_manager.cc b/components/precache/content/precache_manager.cc
index 0395c82a7a4b26c8329b38df25dd2b9e3db9efd0..f4333c12d64e9b02779ca6a8de304a99f2e8bcf5 100644
--- a/components/precache/content/precache_manager.cc
+++ b/components/precache/content/precache_manager.cc
@@ -138,15 +138,19 @@ void PrecacheManager::StartPrecaching(
void PrecacheManager::OnGetUnfinishedWorkDone(
std::unique_ptr<PrecacheUnfinishedWork> unfinished_work) {
- if (!unfinished_work->has_start_time() ||
- base::Time::Now() - base::Time::FromInternalValue(
- unfinished_work->start_time()) > base::TimeDelta::FromHours(6)) {
+ // Reset progress on a prefetch that has taken too long to complete.
+ if (unfinished_work->has_start_time() &&
+ base::Time::Now() -
+ base::Time::FromInternalValue(unfinished_work->start_time()) >
+ base::TimeDelta::FromHours(6)) {
PrecacheFetcher::RecordCompletionStatistics(
*unfinished_work, unfinished_work->top_host_size(),
unfinished_work->resource_size());
- unfinished_work.reset(new PrecacheUnfinishedWork());
- unfinished_work->set_start_time(base::Time::Now().ToInternalValue());
+ unfinished_work.reset(new PrecacheUnfinishedWork);
}
+ // If this prefetch is new, set the start time.
+ if (!unfinished_work->has_start_time())
+ unfinished_work->set_start_time(base::Time::Now().ToInternalValue());
unfinished_work_ = std::move(unfinished_work);
bool needs_top_hosts = unfinished_work_->top_host_size() == 0;
@@ -320,9 +324,11 @@ void PrecacheManager::OnHostsReceived(
const history::TopHostsList& host_counts) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- std::vector<std::string> hosts;
- for (const auto& host_count : host_counts)
- unfinished_work_->add_top_host()->set_hostname(host_count.first);
+ for (const auto& host_count : host_counts) {
+ TopHost* top_host = unfinished_work_->add_top_host();
+ top_host->set_hostname(host_count.first);
+ top_host->set_visits(host_count.second);
+ }
InitializeAndStartFetcher();
}
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698