Index: components/ntp_tiles/popular_sites.h |
diff --git a/components/ntp_tiles/popular_sites.h b/components/ntp_tiles/popular_sites.h |
index 36237a391ab0970aef2ad11491d33ae38667e533..6be324843a0cd24639b5e47fac7ad2b4d484f39d 100644 |
--- a/components/ntp_tiles/popular_sites.h |
+++ b/components/ntp_tiles/popular_sites.h |
@@ -61,19 +61,23 @@ class PopularSites : public net::URLFetcherDelegate { |
using FinishedCallback = base::Callback<void(bool /* success */)>; |
- // When the suggestions have been fetched (from cache or URL) and parsed, |
- // invokes |callback|, on the same thread as the caller. |
- // |
- // Set |force_download| to enforce re-downloading the suggestions file, even |
- // if it already exists on disk. |
PopularSites(const scoped_refptr<base::SequencedWorkerPool>& blocking_pool, |
PrefService* prefs, |
const TemplateURLService* template_url_service, |
variations::VariationsService* variations_service, |
net::URLRequestContextGetter* download_context, |
- const base::FilePath& directory, |
- bool force_download, |
- const FinishedCallback& callback); |
+ const base::FilePath& directory); |
+ |
+ // Starts the process of retrieving popular sites. When they are available, |
+ // invokes |callback| with the result, on the same thread as the caller. Never |
+ // invokes |callback| before returning control to the caller, even if the |
+ // result is immediately known. |
+ // |
+ // Set |force_download| to enforce re-downloading the suggestions file, even |
+ // if it already exists on disk. |
+ // |
+ // Must be called at most once on a given PopularSites object. |
+ void StartFetch(bool force_download, const FinishedCallback& callback); |
~PopularSites() override; |
@@ -104,19 +108,22 @@ class PopularSites : public net::URLFetcherDelegate { |
void ParseSiteList(std::unique_ptr<base::Value> json); |
void OnDownloadFailed(); |
+ // Parameters set from constructor. |
+ scoped_refptr<base::TaskRunner> const blocking_runner_; |
+ PrefService* const prefs_; |
+ const TemplateURLService* const template_url_service_; |
+ variations::VariationsService* const variations_; |
+ net::URLRequestContextGetter* const download_context_; |
+ base::FilePath const local_path_; |
+ |
+ // Set by StartFetch() and called after fetch completes. |
FinishedCallback callback_; |
+ |
std::unique_ptr<net::URLFetcher> fetcher_; |
bool is_fallback_; |
std::vector<Site> sites_; |
GURL pending_url_; |
- base::FilePath local_path_; |
- |
- PrefService* prefs_; |
- net::URLRequestContextGetter* download_context_; |
- |
- scoped_refptr<base::TaskRunner> blocking_runner_; |
- |
base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(PopularSites); |