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

Unified Diff: components/ntp_tiles/popular_sites.h

Issue 2575823002: [Popular Sites] Move PopularSitesImpl to dedicated file (Closed)
Patch Set: Added missing forward declaration. Created 4 years 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.h ('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 104ae63cd313061cd37e6e7829808724c1aa4773..76329526f010a47a5aea2e73e6ca901ea377baf6 100644
--- a/components/ntp_tiles/popular_sites.h
+++ b/components/ntp_tiles/popular_sites.h
@@ -5,44 +5,16 @@
#ifndef COMPONENTS_NTP_TILES_POPULAR_SITES_H_
#define COMPONENTS_NTP_TILES_POPULAR_SITES_H_
-#include <memory>
-#include <string>
#include <vector>
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
-#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
-namespace base {
-class Value;
-}
-
-namespace net {
-class URLRequestContextGetter;
-}
-
-namespace user_prefs {
-class PrefRegistrySyncable;
-}
-
-namespace variations {
-class VariationsService;
-}
-
-class PrefService;
-class TemplateURLService;
-
namespace ntp_tiles {
-using ParseJSONCallback = base::Callback<void(
- const std::string& unsafe_json,
- const base::Callback<void(std::unique_ptr<base::Value>)>& success_callback,
- const base::Callback<void(const std::string&)>& error_callback)>;
-
// Interface to provide a list of suggested popular sites, for display on the
// NTP when there are not enough personalized tiles.
class PopularSites {
@@ -92,73 +64,6 @@ class PopularSites {
virtual std::string GetVersionToFetch() = 0;
};
-// Actual (non-test) implementation of the PopularSites interface. Caches the
-// downloaded file on disk to avoid re-downloading on every startup.
-class PopularSitesImpl : public PopularSites, public net::URLFetcherDelegate {
- public:
- PopularSitesImpl(
- 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,
- ParseJSONCallback parse_json);
-
- ~PopularSitesImpl() override;
-
- // PopularSites implementation.
- void StartFetch(bool force_download,
- const FinishedCallback& callback) override;
- const SitesVector& sites() const override;
- GURL GetLastURLFetched() const override;
- const base::FilePath& local_path() const override;
- GURL GetURLToFetch() override;
- std::string GetCountryToFetch() override;
- std::string GetVersionToFetch() override;
-
- // Register preferences used by this class.
- static void RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* user_prefs);
-
- private:
- void OnReadFileDone(std::unique_ptr<std::string> data, bool success);
-
- // Fetch the popular sites at the given URL, overwriting any file that already
- // exists.
- void FetchPopularSites();
-
- // net::URLFetcherDelegate implementation.
- void OnURLFetchComplete(const net::URLFetcher* source) override;
-
- void OnJsonParsed(std::unique_ptr<base::Value> json);
- void OnJsonParseFailed(const std::string& error_message);
- void OnFileWriteDone(std::unique_ptr<base::Value> json, bool success);
- 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_;
- ParseJSONCallback parse_json_;
-
- // Set by StartFetch() and called after fetch completes.
- FinishedCallback callback_;
-
- std::unique_ptr<net::URLFetcher> fetcher_;
- bool is_fallback_;
- SitesVector sites_;
- GURL pending_url_;
-
- base::WeakPtrFactory<PopularSitesImpl> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PopularSitesImpl);
-};
-
} // namespace ntp_tiles
#endif // COMPONENTS_NTP_TILES_POPULAR_SITES_H_
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/popular_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698