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

Unified Diff: components/ntp_tiles/popular_sites.cc

Issue 2179233003: Start PopularSites fetch from separate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « components/ntp_tiles/popular_sites.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/popular_sites.cc
diff --git a/components/ntp_tiles/popular_sites.cc b/components/ntp_tiles/popular_sites.cc
index 88cccff28762720dd8ccd97c505578935071abeb..90363341ea3d3eee9a99d9c17947633ad333b7de 100644
--- a/components/ntp_tiles/popular_sites.cc
+++ b/components/ntp_tiles/popular_sites.cc
@@ -176,19 +176,26 @@ PopularSites::PopularSites(
const TemplateURLService* template_url_service,
VariationsService* variations_service,
net::URLRequestContextGetter* download_context,
- const base::FilePath& directory,
- bool force_download,
- const FinishedCallback& callback)
- : callback_(callback),
- is_fallback_(false),
+ const base::FilePath& directory)
+ : blocking_runner_(blocking_pool->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)),
+ prefs_(prefs),
+ template_url_service_(template_url_service),
+ variations_(variations_service),
+ download_context_(download_context),
local_path_(directory.empty()
? base::FilePath()
: directory.AppendASCII(kPopularSitesLocalFilename)),
- prefs_(prefs),
- download_context_(download_context),
- blocking_runner_(blocking_pool->GetTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)),
- weak_ptr_factory_(this) {
+ is_fallback_(false),
+ weak_ptr_factory_(this) {}
+
+PopularSites::~PopularSites() {}
+
+void PopularSites::StartFetch(bool force_download,
+ const FinishedCallback& callback) {
+ DCHECK(!callback_);
+ callback_ = callback;
+
const base::Time last_download_time = base::Time::FromInternalValue(
prefs_->GetInt64(kPopularSitesLastDownloadPref));
const base::TimeDelta time_since_last_download =
@@ -198,11 +205,11 @@ PopularSites::PopularSites(
const bool download_time_is_future = base::Time::Now() < last_download_time;
const std::string country =
- GetCountryToUse(prefs, template_url_service, variations_service);
- const std::string version = GetVersionToUse(prefs);
+ GetCountryToUse(prefs_, template_url_service_, variations_);
+ const std::string version = GetVersionToUse(prefs_);
const GURL override_url =
- GURL(prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL));
+ GURL(prefs_->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL));
pending_url_ = override_url.is_valid() ? override_url
: GetPopularSitesURL(country, version);
const bool url_changed =
@@ -231,8 +238,6 @@ PopularSites::PopularSites(
base::Passed(std::move(file_data))));
}
-PopularSites::~PopularSites() {}
-
GURL PopularSites::LastURL() const {
return GURL(prefs_->GetString(kPopularSitesURLPref));
}
« no previous file with comments | « components/ntp_tiles/popular_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698