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

Unified Diff: components/ntp_tiles/popular_sites.h

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/most_visited_sites.cc ('k') | components/ntp_tiles/popular_sites.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « components/ntp_tiles/most_visited_sites.cc ('k') | components/ntp_tiles/popular_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698