Chromium Code Reviews| 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..d551ad729df1e876a6f02040eee3672d22e2bab5 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,13 +139,15 @@ 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)) { |
| + if (!unfinished_work->has_start_time()) |
| + unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); |
| + if (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.reset(new PrecacheUnfinishedWork); |
| unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); |
|
bengr
2016/10/14 21:52:19
Why is start time being set here too?
twifkak
2016/10/14 22:41:45
The first one is what happens on a fresh precache
|
| } |
| unfinished_work_ = std::move(unfinished_work); |
| @@ -320,9 +323,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 +345,9 @@ void PrecacheManager::InitializeAndStartFetcher() { |
| kConfigURLParam)), |
| variations::GetVariationParamValue(kPrecacheFieldTrialName, |
| kManifestURLPrefixParam), |
| + !variations::GetVariationParamValue(kPrecacheFieldTrialName, |
| + kGlobalRankingParam) |
| + .empty(), |
| std::move(unfinished_work_), |
| metrics::HashName( |
| base::FieldTrialList::FindFullName(kPrecacheFieldTrialName)), |