Chromium Code Reviews| 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..9822308ce65b148400311da15a3c919deb09c2c0 100644 |
| --- a/components/ntp_tiles/popular_sites.h |
| +++ b/components/ntp_tiles/popular_sites.h |
| @@ -61,19 +61,21 @@ 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. |
| + void StartFetch(bool force_download, const FinishedCallback& callback); |
|
Marc Treib
2016/07/26 13:46:22
It is legal to call this multiple times? I suppose
sfiera
2016/07/26 13:56:54
No, done, and done.
|
| ~PopularSites() override; |
| @@ -104,19 +106,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); |