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

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

Issue 2403193002: Precache: Optionally rank resources-to-precache globally. (Closed)
Patch Set: 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
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)),
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.h » ('j') | components/precache/core/precache_fetcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698