| 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..97825208430f95a2a8b3dded4145b775e590d245 100644
|
| --- a/components/precache/content/precache_manager.cc
|
| +++ b/components/precache/content/precache_manager.cc
|
| @@ -36,6 +36,7 @@ const char kPrecacheFieldTrialEnabledGroup[] = "Enabled";
|
| const char kPrecacheFieldTrialControlGroup[] = "Control";
|
| const char kConfigURLParam[] = "config_url";
|
| const char kManifestURLPrefixParam[] = "manifest_url_prefix";
|
| +const char kGlobalRankingParam[] = "global_ranking";
|
| const size_t kNumTopHosts = 100;
|
|
|
| } // namespace
|
| @@ -138,15 +139,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 +325,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();
|
| }
|
|
|
| @@ -340,6 +347,9 @@ void PrecacheManager::InitializeAndStartFetcher() {
|
| kConfigURLParam)),
|
| variations::GetVariationParamValue(kPrecacheFieldTrialName,
|
| kManifestURLPrefixParam),
|
| + !variations::GetVariationParamValue(kPrecacheFieldTrialName,
|
| + kGlobalRankingParam)
|
| + .empty(),
|
| std::move(unfinished_work_),
|
| metrics::HashName(
|
| base::FieldTrialList::FindFullName(kPrecacheFieldTrialName)),
|
|
|